SFML community forums

General => General discussions => Topic started by: aeron on February 03, 2011, 11:28:24 pm

Title: Problem compiling SFML 2.0 program
Post by: aeron on February 03, 2011, 11:28:24 pm
I followed the instructions to build SFML 2.0 with CMake and it seemed to work without a problem. So now I try to compile against the library but I keep getting errors:
Code: [Select]
obj\Debug\Game.o: In function `Game':
C:/Users/Mitchell/Programming/Projects/Demise/Game.cpp:13: undefined reference to `_imp___ZN2sf9VideoModeC1Ejjj'
C:/Users/Mitchell/Programming/Projects/Demise/Game.cpp:13: undefined reference to `_imp___ZN2sf12RenderWindowC1ENS_9VideoModeERKSsmRKNS_15ContextSettingsE'
C:/Users/Mitchell/Programming/Projects/Demise/Game.cpp:14: undefined reference to `_imp___ZN2sf6Window17SetFramerateLimitEj'
C:/Users/Mitchell/Programming/Projects/Demise/Game.cpp:27: undefined reference to `_imp___ZN2sf5ImageC1Ev'
C:/Users/Mitchell/Programming/Projects/Demise/Game.cpp:28: undefined reference to `_imp___ZN2sf5Image12LoadFromFileERKSs'
C:/Users/Mitchell/Programming/Projects/Demise/Game.cpp:30: undefined reference to `_imp___ZN2sf5Image9SetSmoothEb'
C:/Users/Mitchell/Programming/Projects/Demise/Game.cpp:13: undefined reference to `_imp___ZN2sf9VideoModeC1Ejjj'
C:/Users/Mitchell/Programming/Projects/Demise/Game.cpp:13: undefined reference to `_imp___ZN2sf12RenderWindowC1ENS_9VideoModeERKSsmRKNS_15ContextSettingsE'
C:/Users/Mitchell/Programming/Projects/Demise/Game.cpp:14: undefined reference to `_imp___ZN2sf6Window17SetFramerateLimitEj'
C:/Users/Mitchell/Programming/Projects/Demise/Game.cpp:27: undefined reference to `_imp___ZN2sf5ImageC1Ev'
C:/Users/Mitchell/Programming/Projects/Demise/Game.cpp:28: undefined reference to `_imp___ZN2sf5Image12LoadFromFileERKSs'
C:/Users/Mitchell/Programming/Projects/Demise/Game.cpp:30: undefined reference to `_imp___ZN2sf5Image9SetSmoothEb'
obj\Debug\Game.o:C:/Users/Mitchell/Programming/Projects/Demise/Game.cpp:58: undefined reference to `_imp___ZN2sf6Window5CloseEv'
obj\Debug\Game.o:C:/Users/Mitchell/Programming/Projects/Demise/Game.cpp:55: undefined reference to `_imp___ZN2sf6Window8GetEventERNS_5EventE'
obj\Debug\Game.o:C:/Users/Mitchell/Programming/Projects/Demise/Game.cpp:60: undefined reference to `_imp___ZNK2sf6Window8GetInputEv'
obj\Debug\Game.o:C:/Users/Mitchell/Programming/Projects/Demise/Game.cpp:63: undefined reference to `_imp___ZN2sf5Color5BlackE'
obj\Debug\Game.o:C:/Users/Mitchell/Programming/Projects/Demise/Game.cpp:63: undefined reference to `_imp___ZN2sf12RenderTarget5ClearERKNS_5ColorE'
obj\Debug\Game.o:C:/Users/Mitchell/Programming/Projects/Demise/Game.cpp:65: undefined reference to `_imp___ZN2sf6Window7DisplayEv'
obj\Debug\Game.o:C:/Users/Mitchell/Programming/Projects/Demise/Game.cpp:52: undefined reference to `_imp___ZNK2sf6Window8IsOpenedEv'
collect2: ld returned 1 exit status


So yeah, what might cause this? The program is trivially simple, it's just a basic game loop at the moment. I have the compiler/linker search directories set correctly and everything, and I'm using the exact same compiler I used to compile SFML (TDM-GCC). Using SVN revision 1786
Title: Problem compiling SFML 2.0 program
Post by: Laurent on February 03, 2011, 11:43:13 pm
Are you linking statically?
Title: Problem compiling SFML 2.0 program
Post by: aeron on February 03, 2011, 11:45:59 pm
Yes.

Edit: Strangely enough, compiling against the dynamic libraries works just fine.
Title: Problem compiling SFML 2.0 program
Post by: Laurent on February 03, 2011, 11:49:25 pm
Not strangely. Static linking requires the SFML_STATIC preprocessor macro to be defined.
Title: Problem compiling SFML 2.0 program
Post by: aeron on February 03, 2011, 11:56:26 pm
Ah sounds familiar, but.. Did you always have to do this? I can't remember if I had to use it in 1.7 or not. Regardless, it's working great now, thanks for the help Laurent!
Title: Problem compiling SFML 2.0 program
Post by: OniLinkPlus on February 04, 2011, 01:52:16 am
There isn't a 1.7. And it's new to SFML2.
Title: Problem compiling SFML 2.0 program
Post by: bmn on February 04, 2011, 03:38:55 am
Quote from: "OniLink10"
There isn't a 1.7. And it's new to SFML2.


The Download Page (http://www.sfml-dev.org/download.php) list the latest non SFML2 trunk as SFML 1.7
Title: Problem compiling SFML 2.0 program
Post by: Laurent on February 04, 2011, 07:29:38 am
In SFML 1.x it was SFML_DYNAMIC for dynamic libraries.

SFML 1.7 will never exist, but that's how the current trunk is named, until the sfml2 branch is merged into it.
Title: Problem compiling SFML 2.0 program
Post by: aeron on February 04, 2011, 09:06:54 am
Quote

The Download Page list the latest non SFML2 trunk as SFML 1.7

Yeah that's what I checked but I meant 1.6.

Quote
In SFML 1.x it was SFML_DYNAMIC for dynamic libraries.

Sounds right, that's what I was thinking about.
Title: problem compiling SFML 2.0 program
Post by: christian.kelvin10 on March 12, 2011, 02:42:44 pm
I am trying to use your particle engine with Sfml and got some problems. I have the exact same code as in tutorial 2  and linked all right. Static SFML libraries and static libraries to IGNITE. There are no linker error, but when I try to compile it is a strange error without assistance: