Undefined reference while linking tgui statically on Windows

Started by knarf0, 11 September 2014, 23:20:51

knarf0

Hi,

I would like to compile a project on Windows using mingw32, with both SFML and TGUI linked statically.

I Compile with :

Quoteg++ main.cpp -o main.exe -W -Wall -std=c++11 -DSFML_STATIC -DTGUI_USE_STATIC_STD_LIBS -ltgui-s -lsfml-graphics-s -lsfml-window-s -lsfml-network-s -lsfml-audio-s -lsfml-system-s

and I get :

Quotec:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x429): undefined reference to `__gxx_personality_sj0'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x43d): undefined reference to `_Unwind_SjLj_Register'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x524): undefined reference to `_Unwind_SjLj_Unregister'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x590): undefined reference to `__gxx_personality_sj0'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x5b2): undefined reference to `_Unwind_SjLj_Register'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x629): undefined reference to `_Unwind_SjLj_Unregister'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x68c): undefined reference to `_Unwind_SjLj_Resume'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x6c1): undefined reference to `__gxx_personality_sj0'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x6e9): undefined reference to `_Unwind_SjLj_Register'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x738): undefined reference to `_Unwind_SjLj_Unregister'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x82c): undefined reference to `_Unwind_SjLj_Resume'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x83d): undefined reference to `__gxx_personality_sj0'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x865): undefined reference to `_Unwind_SjLj_Register'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x8a7): undefined reference to `_Unwind_SjLj_Unregister'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x969): undefined reference to `_Unwind_SjLj_Resume'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0xca4): undefined reference to `__gxx_personality_sj0'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0xccc): undefined reference to `_Unwind_SjLj_Register'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0xd70): undefined reference to `_Unwind_SjLj_Unregister'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0xdad): undefined reference to `_Unwind_SjLj_Resume'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0xe18): undefined reference to `__gxx_personality_sj0'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0xe43): undefined reference to `_Unwind_SjLj_Register'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x124c): undefined reference to `_Unwind_SjLj_Unregister'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x1396): undefined reference to `_Unwind_SjLj_Resume'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x1404): undefined reference to `__gxx_personality_sj0'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x142c): undefined reference to `_Unwind_SjLj_Register'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x14eb): undefined reference to `_Unwind_SjLj_Unregister'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x153b): undefined reference to `_Unwind_SjLj_Resume'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x161c): undefined reference to `__gxx_personality_sj0'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x1630): undefined reference to `_Unwind_SjLj_Register'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x1659): undefined reference to `_Unwind_SjLj_Unregister'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x1670): undefined reference to `__gxx_personality_sj0'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x1698): undefined reference to `_Unwind_SjLj_Register'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x1853): undefined reference to `_Unwind_SjLj_Unregister'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x18a3): undefined reference to `_Unwind_SjLj_Resume'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x18dc): undefined reference to `__gxx_personality_sj0'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x1904): undefined reference to `_Unwind_SjLj_Register'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x19ca): undefined reference to `_Unwind_SjLj_Unregister'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x1ab1): undefined reference to `_Unwind_SjLj_Resume'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x1ac5): undefined reference to `__gxx_personality_sj0'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x1aed): undefined reference to `_Unwind_SjLj_Register'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x1bc0): undefined reference to `_Unwind_SjLj_Unregister'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x1d06): undefined reference to `_Unwind_SjLj_Resume'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x1d1b): undefined reference to `__gxx_personality_sj0'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x1d43): undefined reference to `_Unwind_SjLj_Register'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x1eb5): undefined reference to `_Unwind_SjLj_Unregister'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x1fdc): undefined reference to `_Unwind_SjLj_Resume'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x2001): undefined reference to `_Unwind_SjLj_Resume'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x2015): undefined reference to `__gxx_personality_sj0'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x203d): undefined reference to `_Unwind_SjLj_Register'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x20f6): undefined reference to `_Unwind_SjLj_Unregister'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x2550): undefined reference to `_Unwind_SjLj_Resume'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x2575): undefined reference to `_Unwind_SjLj_Resume'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x259a): undefined reference to `_Unwind_SjLj_Resume'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x25c3): undefined reference to `_Unwind_SjLj_Resume'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x2834): undefined reference to `__gxx_personality_sj0'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x285c): undefined reference to `_Unwind_SjLj_Register'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x29a9): undefined reference to `_Unwind_SjLj_Unregister'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x2a07): undefined reference to `_Unwind_SjLj_Resume'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x2a2c): undefined reference to `_Unwind_SjLj_Resume'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x2a44): undefined reference to `__gxx_personality_sj0'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x2a6c): undefined reference to `_Unwind_SjLj_Register'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x2bbd): undefined reference to `_Unwind_SjLj_Unregister'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x2c29): undefined reference to `_Unwind_SjLj_Resume'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x2c4e): undefined reference to `_Unwind_SjLj_Resume'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x2c61): undefined reference to `__gxx_personality_sj0'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x2c89): undefined reference to `_Unwind_SjLj_Register'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x2d44): undefined reference to `_Unwind_SjLj_Unregister'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x2d77): undefined reference to `_Unwind_SjLj_Resume'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x2d89): undefined reference to `__gxx_personality_sj0'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x2dab): undefined reference to `_Unwind_SjLj_Register'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x2e54): undefined reference to `_Unwind_SjLj_Unregister'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x41f9): undefined reference to `_Unwind_SjLj_Resume'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x425a): undefined reference to `_Unwind_SjLj_Resume'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x4454): undefined reference to `__gxx_personality_sj0'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x447f): undefined reference to `_Unwind_SjLj_Register'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x4968): undefined reference to `_Unwind_SjLj_Unregister'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x49f6): undefined reference to `_Unwind_SjLj_Resume'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x4a99): undefined reference to `__gxx_personality_sj0'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x4ac1): undefined reference to `_Unwind_SjLj_Register'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x4d7c): undefined reference to `_Unwind_SjLj_Unregister'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x4de0): undefined reference to `_Unwind_SjLj_Resume'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x4e05): undefined reference to `_Unwind_SjLj_Resume'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x4ed8): undefined reference to `__gxx_personality_sj0'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x4f00): undefined reference to `_Unwind_SjLj_Register'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x4fa0): undefined reference to `_Unwind_SjLj_Unregister'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x5039): undefined reference to `_Unwind_SjLj_Resume'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x5052): undefined reference to `__gxx_personality_sj0'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x507d): undefined reference to `_Unwind_SjLj_Register'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x50e0): undefined reference to `_Unwind_SjLj_Unregister'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x5423): undefined reference to `_Unwind_SjLj_Resume'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x5448): undefined reference to `__gxx_personality_sj0'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x5479): undefined reference to `_Unwind_SjLj_Register'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x58c5): undefined reference to `_Unwind_SjLj_Unregister'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x854f): undefined reference to `_Unwind_SjLj_Resume'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj):Container.cpp:(.text+0x8572): undefined reference to `_Unwind_SjLj_Resume'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libtgui-s.a(Container.cpp.obj): bad reloc address 0x24 in section `.rdata'
collect2.exe: error: ld returned 1 exit status

thanks for your help

texus

Using TGUI_USE_STATIC_STD_LIBS has never really been tested, but I don't see a reason why it shouldn't work.

It is however a setting that has to be given when compiling the tgui libraries, not when compiling your own application. The precompiled libraries are compiled without this option, so if you want to use it then you must compile tgui yourself with CMake and enable the option there. Make sure that the sfml libraries that tgui finds during compilation are the same as you use in your project and where compiled with SFML_USE_STATIC_STD_LIBS.

Edit: You didn't use the precompiled libraries did you? Your compiler is incompatible with them anyway.

knarf0

Okay it seems a lot of trouble, I think I will link dynamically but I also have some trouble with this.

I can compile both SFML example and TGUI example with
Quotei586-mingw32msvc-g++ main.cpp -o main.exe -W -Wall -ltgui -lsfm l-graphics -lsfml-window -lsfml-network -lsfml-audio -lsfml-system -std=c++11
without errors, the SFML example works fine (Pong) but when I launch the TGUI example I got this error from wine or windows (tested on both) :

QuoteCall from 0x7bc4c2c0 to unimplemented function sfml-graphics-2.dll._ZN2sf5ImageD1Ev, aborting
I'm using the same .dll files in both cases.

I really don't know what to do from here.

texus

SFML_USE_STATIC_STD_LIBS and TGUI_USE_STATIC_STD_LIBS are only required to link statically to the system libraries as well, they are not required (and by default not used) for static linking. You can perfectly use sfml and tgui statically while not checking this option in cmake.

Anyway, first priority should probably be to get something working no matter how it is linked. Then you can still mess around and try to get static linking working if you want it.

QuoteCall from 0x7bc4c2c0 to unimplemented function sfml-graphics-2.dll._ZN2sf5ImageD1Ev, aborting
I have seen a similar error on linux before not so long ago, so this time I do know what is wrong.
The latest sfml version has a destructor in the Image class, while sfml 2.1 did not have this yet.
So it looks like your dll is still from sfml 2.1 while you (or the tgui libs) linked to a newer sfml version.

Edit: Did you compile tgui yourself?

knarf0

Thank you for your help.

I think the problem was because I used my own sfml libs instead of the ones provided for Tgui.

I do not try to cross-compile anymore, I just installed code blocks on Windows and installed tgui using the tutorial and it all works fine :)