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

Author Topic: Updating SFML 1.6 to 2.0 (C++)  (Read 3856 times)

0 Members and 1 Guest are viewing this topic.

TheLastBanana

  • Newbie
  • *
  • Posts: 10
    • View Profile
Updating SFML 1.6 to 2.0 (C++)
« on: October 21, 2010, 06:34:38 am »
Hey there!
I've been working on a project for a while in SFML 1.6, and a lot of the functions in 2.0 seem really useful to me, so I've decided to upgrade. I grabbed the latest snapshot off the website and compiled it, but now I'm having a bit of a problem:
I've linked my project to all the necessary sfml2-x libraries and I replaced the include files with the new ones. However, I'm getting a lot of errors when I try to compile my project, starting with:
Code: [Select]
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.0\..\..\..\libsfml2-graphics-s.a(Font.o):Font.cpp|| multiple definition of `sf::Font::~Font()'|
obj\Release\AnimSprite.o:AnimSprite.cpp|| undefined reference to `sf::Sprite::SetImage(sf::Image const&)'|
obj\Release\AnimSprite.o:AnimSprite.cpp|| undefined reference to `sf::Drawable::SetCenter(float, float)'|

And so on.
I tried compiling a new program using the sample code from the Code::Blocks setup page, and it compiled just fine. I used the exact same linker settings, so I'm wondering why it would be throwing me these errors.
I'm using Code::Blocks with MinGW as compiler, and if it makes any difference, I'm having g++ use the new C++0x standard.
Any help would be appreciated. Thanks!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Updating SFML 1.6 to 2.0 (C++)
« Reply #1 on: October 21, 2010, 07:54:04 am »
How did you compile SFML? Can you show the linker options of your project?
Laurent Gomila - SFML developer

TheLastBanana

  • Newbie
  • *
  • Posts: 10
    • View Profile
Updating SFML 1.6 to 2.0 (C++)
« Reply #2 on: October 22, 2010, 02:35:24 am »
I compiled SFML from the build\codeblocks\SFML.workspace file. In order to get it to compile, I had to add -ws2_32, because it was throwing me errors regarding missing network functions.
My linker settings for the project itself are as follows:
Code: [Select]
-static-libgcc
-lsfml2-audio-s
-lsfml2-graphics-s
-lsfml2-window-s
-lsfml2-main
-lsfml2-system-s

Thanks for replying so quickly!

EDIT:
I also tried recompiling SFML2 using both my regular Code::Blocks installation of MinGW and another, almost clean install of it, but both are giving me the same errors at compile time.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Updating SFML 1.6 to 2.0 (C++)
« Reply #3 on: October 22, 2010, 08:08:52 am »
I think you're still using the SFML 1.6 headers. Drawable::SetCenter no longer exists in SFML 2.
Laurent Gomila - SFML developer

TheLastBanana

  • Newbie
  • *
  • Posts: 10
    • View Profile
Updating SFML 1.6 to 2.0 (C++)
« Reply #4 on: October 22, 2010, 11:59:03 pm »
That's likely why it's throwing those errors, then - the reference to SetCenter is in my own code. I'm using the current headers as far as I know. I'm still a bit puzzled by the multiple definition error, though.
EDIT EDIT:
Nevermind, I think I was just getting a different compile error first. I'm still getting the "multiple definition of `sf::Font::~Font()'" error. If I don't use any Font functions in main.cpp, it doesn't give me this error. Is there any way I could fix this?
As well, now that I look at it, I'm getting these errors in the linking stage, so that means that you're right about the headers being outdated. That said, I've checked the headers, and they're definitely the new ones. Maybe I'm experiencing some strange Code::Blocks quirk?

EDIT EDIT EDIT:
Okay, I found the problem. Code::Blocks had an old version of SFML set as a default search directory, but I had forgotten that. It doesn't show up in the project settings, so I didn't notice. It was getting outdated headers from there, but a new version of the library, which was causing the problems.
Thanks anyway!

 

anything