Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: SFML2 Linking Errors  (Read 4631 times)

0 Members and 1 Guest are viewing this topic.

TheLastBanana

  • Newbie
  • *
  • Posts: 10
    • View Profile
SFML2 Linking Errors
« on: November 08, 2010, 06:35:51 am »
I've been trying to compile SFML2 using CMake from the latest snapshot. SFML2 compiles fine, but whenever I try to start a project with it, I get hundreds of errors like this in the linking stage (from within my own code):
Code: [Select]
obj\Release\AnimSprite.o:AnimSprite.cpp|| undefined reference to `_imp___ZN2sf6SpriteC1Ev'|
Currently, the lib and include files are installed directly into my MinGW folder. However, I've also tried using the install make and adding the Program Files\SFML directories as search directories, but it gave the exact same errors.
I'm compiling using Code::Blocks and MinGW, and compiled SFML using CMake and a clean install of MinGW.
Any help would be appreciated. Thanks!

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
SFML2 Linking Errors
« Reply #1 on: November 08, 2010, 06:54:35 am »
Are you giving the compiler the correct linker flags? -lsfml-system, -lsfml-window, etc. etc. Haven't compiled SFML2 for Windows, thinks this is changed there so might be something like -lsfml-system2 or something. Not sure. Just check the name of the library file under MinGW/lib and remove the prefix lib and the file extension to get the correct linker flag.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

TheLastBanana

  • Newbie
  • *
  • Posts: 10
    • View Profile
SFML2 Linking Errors
« Reply #2 on: November 08, 2010, 07:04:45 am »
My linker settings are as follows:
Code: [Select]
-lsfml-audio-s
-lsfml-graphics-s
-lsfml-main
-lsfml-window-s
-lsfml-system-s
-static-libgcc

I have a bit of a bad track record with missing some minor mistake in linking and spending days trying to fix it, so it's entirely possible that I'm missing something :P

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
SFML2 Linking Errors
« Reply #3 on: November 08, 2010, 07:10:00 am »
As I said, the naming convention is changed for SFML2. Try looking into your MinGW/lib folder to see what the names of your library files are.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

TheLastBanana

  • Newbie
  • *
  • Posts: 10
    • View Profile
SFML2 Linking Errors
« Reply #4 on: November 08, 2010, 07:16:24 am »
The files I'm linking to are named "libsfml-audio-s.a", "libsfml-graphics-s.a" and so on.

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
SFML2 Linking Errors
« Reply #5 on: November 08, 2010, 07:25:11 am »
I doubt it is because you've defined SFML_DYNAMIC anywhere even though your linking it statically ( I think that's removed from SFML2 ). Does it work on debug mode for Code::Blocks with the debug libraries?

Code::Blocks are telling you "Linking blah blah" with the libraries?
Also I'm wondering, why are you linking with sfml-main? If I remember correctly, not needed anymore and absolutely not on MinGW.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

TheLastBanana

  • Newbie
  • *
  • Posts: 10
    • View Profile
SFML2 Linking Errors
« Reply #6 on: November 08, 2010, 07:38:32 am »
Oh, I threw sfml-main in there after it refused to build. It didn't do anything, obviously, but I forgot to take it out.
I just tried compiling it in Debug with the debug libraries, but I got the same errors.
The Build Log tells me that everything has compiled, but gets the errors after "Linking executable". SFML_DYNAMIC is definitely not defined anywhere.
If it's worth anything, my compiler is following C++0x standards.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
SFML2 Linking Errors
« Reply #7 on: November 08, 2010, 07:46:00 am »
You must define SFML_STATIC.
Laurent Gomila - SFML developer

TheLastBanana

  • Newbie
  • *
  • Posts: 10
    • View Profile
SFML2 Linking Errors
« Reply #8 on: November 08, 2010, 07:53:13 am »
I'm using CMake and setting BUILD_SHARED_LIBS to false - shouldn't SFML_STATIC already be defined?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
SFML2 Linking Errors
« Reply #9 on: November 08, 2010, 08:06:35 am »
Quote
shouldn't SFML_STATIC already be defined?

Certainly not in your own project ;)
Laurent Gomila - SFML developer

TheLastBanana

  • Newbie
  • *
  • Posts: 10
    • View Profile
SFML2 Linking Errors
« Reply #10 on: November 08, 2010, 08:09:51 am »
Ah, that explains it! :oops:
Thanks for your help.

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
SFML2 Linking Errors
« Reply #11 on: November 08, 2010, 08:56:25 am »
Ah right, DAMN! Forgot about that change. I could have made this thread so much shorter.  :oops:
Developer and Maker of rbSFML and Programmer at Paradox Development Studio