SFML community forums

Help => General => Topic started by: NordCoder on May 12, 2011, 12:02:31 am

Title: Undefined references when linking statically
Post by: NordCoder on May 12, 2011, 12:02:31 am
I am trying to link SFML 1.6 to my project in Code::Blocks 10.05 with MingW 4.4.1

I followed this (http://www.sfml-dev.org/tutorials/1.6/start-cb.php) tutorial and used the same source code used as an example.

I am getting the following errors:
Code: [Select]

||=== SFML_test, Debug ===|
E:\Tools\SFML\SFML-1.6\lib\libsfml-system-s-d.a(Clock.o):Clock.cpp:(.eh_frame+0x11)||undefined reference to `__gxx_personality_v0'|
E:\Tools\SFML\SFML-1.6\lib\libsfml-system-s-d.a(Sleep.o):Sleep.cpp:(.eh_frame+0x11)||undefined reference to `__gxx_personality_v0'|
E:\Tools\SFML\SFML-1.6\lib\libsfml-system-s-d.a(Platform.o):D:\dev\sfml\sdk\SFML-1.6\src\SFML\System\Win32\Platform.cpp|42|undefined reference to `_Unwind_Resume'|
E:\Tools\SFML\SFML-1.6\lib\libsfml-system-s-d.a(Platform.o):Platform.cpp:(.eh_frame+0x12)||undefined reference to `__gxx_personality_v0'|
||=== Build finished: 4 errors, 0 warnings ===|


I know this question has probably been asked a dozen times or more but before posting I: Reread the tutorial, searched the internet and double-checked the settings/options in Code::Blocks.

Additionally, I added the SFML_DYNAMIC define and "-lsfml-system-s-d" and copied "libgcc_s_dw2-1.dll" and "sfml-system-d.dll" to my project executable's directory and got it to work (in Debug configuration). I should also mention that "libgcc_s_dw2-1.dll" was to located in the MingW version I have (found "libgcc_s_sjlj-1.dll" instead). I got this .dll from the download suggested in the beginning of the tutorial. I still want to make it work with the static libraries though :)
Title: Undefined references when linking statically
Post by: Laurent on May 12, 2011, 07:40:54 am
Quote
Additionally, I added the SFML_DYNAMIC define

Which is for dynamic link, not static ;)

Quote
I should also mention that "libgcc_s_dw2-1.dll" was to located in the MingW version I have (found "libgcc_s_sjlj-1.dll" instead)

So it means that your MinGW is not compatible with the one that was used to compile SFML. You can recompile SFML with yours, or download the version I used (the link is provided in the Code::Blocks tutorial).
Title: Undefined references when linking statically
Post by: NordCoder on May 13, 2011, 08:05:48 am
Quote
Which is for dynamic link, not static ;)


It may not have been clear what I was trying to say but I only used the define when I compiled dynamically :)

Switching the path under Settings -> Compiler and debugger... -> Global compiler settings -> Toolchain executables -> Compiler's installation directory to the path of the MingW version you suggest in the tutorial makes it work flawlessly for static linking :D I also managed to circumvent the fps issues (very low delta-times) I experienced on my laptop a while back. Maybe I need to update my drivers or OpenGL version?

Anyway, thank you for your help :)