MINGW-packages: [SDL2_ttf] Missing C++ symbols statically linked with C
Description / Steps to reproduce the issue
When statically linking “SDL2_ttf” in a C project, the linker throws errors for missing symbols. This can be worked around by including “stdlibc++”, but this shouldn’t be required?
Error
"cc" -o example.exe example.exe.p/main.c.obj "-Wl,--start-group" "C:/Development/MSYS2/clang64/bin/../lib/libmingw32.a" "-mwindows" "C:/Development/MSYS2/clang64/bin/../lib/libSDL2main.a" "C:/Development/MSYS2/clang64/bin/../lib/libSDL2.a" "-mwindows" "-lm" "C:/Development/MSYS2/clang64/bin/../lib/libkernel32.a" "C:/Development/MSYS2/clang64/bin/../lib/libuser32.a" "C:/Development/MSYS2/clang64/bin/../lib/libgdi32.a" "C:/Development/MSYS2/clang64/bin/../lib/libwinmm.a" "C:/Development/MSYS2/clang64/bin/../lib/libimm32.a" "C:/Development/MSYS2/clang64/bin/../lib/libole32.a" "C:/Development/MSYS2/clang64/bin/../lib/liboleaut32.a" "C:/Development/MSYS2/clang64/bin/../lib/libversion.a" "C:/Development/MSYS2/clang64/bin/../lib/libuuid.a" "C:/Development/MSYS2/clang64/bin/../lib/libadvapi32.a" "C:/Development/MSYS2/clang64/bin/../lib/libsetupapi.a" "C:/Development/MSYS2/clang64/bin/../lib/libshell32.a" "C:/Development/MSYS2/clang64/bin/../lib/libdinput8.a" "C:/Development/MSYS2/clang64/bin/../lib/libSDL2_ttf.a" "-mwindows" "-mwindows" "C:/Development/MSYS2/clang64/bin/../lib/libbrotlicommon.a" "C:/Development/MSYS2/clang64/bin/../lib/libpng16.a" "C:/Development/MSYS2/clang64/bin/../lib/libz.a" "C:/Development/MSYS2/clang64/bin/../lib/libharfbuzz.a" "C:/Development/MSYS2/clang64/bin/../lib/libusp10.a" "C:/Development/MSYS2/clang64/bin/../lib/librpcrt4.a" "C:/Development/MSYS2/clang64/bin/../lib/libfreetype.a" "C:/Development/MSYS2/clang64/bin/../lib/libbz2.a" "C:/Development/MSYS2/clang64/bin/../lib/libglib-2.0.a" "C:/Development/MSYS2/clang64/bin/../lib/libintl.a" "C:/Development/MSYS2/clang64/bin/../lib/libws2_32.a" "C:/Development/MSYS2/clang64/bin/../lib/libshlwapi.a" "C:/Development/MSYS2/clang64/bin/../lib/libpcre2-8.a" "C:/Development/MSYS2/clang64/bin/../lib/libgraphite2.a" "C:/Development/MSYS2/clang64/bin/../lib/libbrotlidec.a" "-Wl,--subsystem,console" "-lkernel32" "-luser32" "-lgdi32" "-lwinspool" "-lshell32" "-lole32" "-loleaut32" "-luuid" "-lcomdlg32" "-ladvapi32" "-Wl,--end-group"
ld.lld: error: undefined symbol: operator new(unsigned long long)
>>> referenced by libharfbuzz.a(hb-directwrite.cc.obj):(_hb_directwrite_shaper_face_data_create)
>>> referenced by libharfbuzz.a(hb-directwrite.cc.obj):(_hb_directwrite_shaper_face_data_create)
>>> referenced by libharfbuzz.a(hb-directwrite.cc.obj):(_hb_directwrite_shaper_face_data_create)
>>> referenced 2 more times
ld.lld: error: undefined symbol: operator delete(void*)
>>> referenced by libharfbuzz.a(hb-directwrite.cc.obj):(_hb_directwrite_shaper_face_data_destroy)
>>> referenced by libharfbuzz.a(hb-directwrite.cc.obj):(_hb_directwrite_shape)
>>> referenced by libharfbuzz.a(hb-directwrite.cc.obj):(DWriteFontFileStream::~DWriteFontFileStream())
>>> referenced 1 more times
ld.lld: error: undefined symbol: operator new[](unsigned long long)
>>> referenced by libharfbuzz.a(hb-directwrite.cc.obj):(_hb_directwrite_shape)
>>> referenced by libharfbuzz.a(hb-directwrite.cc.obj):(_hb_directwrite_shape)
>>> referenced by libharfbuzz.a(hb-directwrite.cc.obj):(_hb_directwrite_shape)
>>> referenced 3 more times
ld.lld: error: undefined symbol: operator delete[](void*)
>>> referenced by libharfbuzz.a(hb-directwrite.cc.obj):(_hb_directwrite_shape)
>>> referenced by libharfbuzz.a(hb-directwrite.cc.obj):(_hb_directwrite_shape)
>>> referenced by libharfbuzz.a(hb-directwrite.cc.obj):(_hb_directwrite_shape)
>>> referenced 5 more times
ld.lld: error: undefined symbol: __cxa_call_unexpected
>>> referenced by libgraphite2.a(gr_face.cpp.obj):(gr_make_face_with_ops)
>>> referenced by libgraphite2.a(gr_face.cpp.obj):(gr_make_face_with_ops)
>>> referenced by libgraphite2.a(Face.cpp.obj):(graphite2::Face::nameTable() const)
>>> referenced 41 more times
ld.lld: error: undefined symbol: __gxx_personality_seh0
>>> referenced by libgraphite2.a(gr_face.cpp.obj):(.xdata)
>>> referenced by libgraphite2.a(gr_face.cpp.obj):(GCC_except_table0)
>>> referenced by libgraphite2.a(gr_features.cpp.obj):(.xdata)
>>> referenced 30 more times
ld.lld: error: undefined symbol: vtable for __cxxabiv1::__class_type_info
>>> referenced by libgraphite2.a(Face.cpp.obj):(typeinfo for graphite2::Face)
>>> referenced by libgraphite2.a(CmapCache.cpp.obj):(typeinfo for graphite2::Cmap)
ld.lld: error: undefined symbol: vtable for __cxxabiv1::__si_class_type_info
>>> referenced by libgraphite2.a(CmapCache.cpp.obj):(typeinfo for graphite2::CachedCmap)
>>> referenced by libgraphite2.a(CmapCache.cpp.obj):(typeinfo for graphite2::DirectCmap)
cc: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
Minimal reproduction
main.c;
#include <SDL2/SDL.h>
#include <SDL2/SDL_ttf.h>
int main(int argc, char *argv[]) {
TTF_Font* font = TTF_OpenFontRW(SDL_RWFromConstMem(NULL, 0), 1, 16);
TTF_SetFontStyle(font, TTF_STYLE_NORMAL);
return 0;
}
meson.build:
project('example', 'c', version: '1.0.0')
executable(
'example', ['main.c'],
dependencies: [
dependency('sdl2', static: true),
dependency('sdl2_ttf', static: true)
]
)
Expected behavior
The project is successfully linked.
Actual behavior
The linker throws an error for missing “stdlibc++” symbols.
Verification
- I have verified that my MSYS2 is up-to-date before submitting the report (see https://www.msys2.org/docs/updating/)
Windows Version
MSYS_NT-10.0-19045
MINGW environments affected
- MINGW64
- MINGW32
- UCRT64
- CLANG64
- CLANG32
- CLANGARM64
Are you willing to submit a PR?
Probably not 😦
About this issue
- Original URL
- State: open
- Created 2 months ago
- Comments: 15 (6 by maintainers)
I agree. It’s not clear to me where this could/should be improved though.