SFML community forums

Help => General => Topic started by: Birdron on October 03, 2023, 08:47:44 am

Title: Undefined Reference Error
Post by: Birdron on October 03, 2023, 08:47:44 am
I just compiled SFML using cmake. And it only build static lib I think. I have attached the image of the build. Now when I try to compile hello world it says -
(click to show/hide)
Prebuild SFML is also showing same error. Version 2.6.
Title: Re: Undefined Reference Error
Post by: eXpl0it3r on October 03, 2023, 09:07:28 pm
Are you linking SFML? And have you defined SFML_STATIC?
Title: Re: Undefined Reference Error
Post by: Birdron on October 03, 2023, 10:18:20 pm
Yes, I have linked sfml and defined SFML_STATIC. It was actually gcc version problem, I think. When I used prebuilt library of 2.6, it compiled without any error but when I run the app I get:- "libgcc_s_seh-1.dll not found" error. When I compiled sfml with tdm-gcc 10 I got this undefined reference error. So I removed tdm-gcc and downloaded codeblock with compiler and downloaded sfml 2.5. Now it is working without error.
Title: Re: Undefined Reference Error
Post by: eXpl0it3r on November 11, 2023, 11:04:14 am
TDM links the runtime library statically by default, which other MinGW distribution link them dynamically (matching the default behavior of GCC or Clang anywhere else).

If you want to link the runtime libraries statically, you have to rebuild SFML with SFML_USE_STATIC_STD_LIBS (https://www.sfml-dev.org/tutorials/2.6/compile-with-cmake.php#:~:text=of%20this%20option.-,SFML_USE_STATIC_STD_LIBS,-(Windows%20only)) enabled.