SFML community forums

Help => General => Topic started by: Trunks7j on March 17, 2010, 06:38:07 am

Title: Static library linking with mingw on windows
Post by: Trunks7j on March 17, 2010, 06:38:07 am
Hey guys,

I've been coding with SFML (amazing!!) for a while in Eclipse, on windows XP, with minGW as my compiler.  I'm trying to switch from the dynamic libraries to static, so i replaced my library table:
Code: [Select]
sfml-system
sfml-audio
sfml-window
sfml-graphics

with this:
Code: [Select]
sfml-system-s
sfml-audio-s
sfml-window-s
sfml-graphics-s


However I am now getting many undefined references.  Here is a sample of the first few lines.

Code: [Select]
g++ -orun.exe src\main.o src\Terrain.o src\Static.o src\SoundManager.o src\Scene.o src\Player.o src\ParticleSystem.o src\Level.o src\InputListener.o src\ImageManager.o src\FrameListener.o src\Entity.o src\Editor.o -lsfml-system-s -lsfml-main -lsfml-audio-s -lsfml-window-s -lsfml-graphics-s -llibboost_serialization-mgw34-mt -lSPARK -lSPARK_GL -lSPARK_SFML
/mingw/lib/libsfml-window-s.a(Window.o):Window.cpp:(.text+0x3cb): undefined reference to `sf::Sleep(float)'
/mingw/lib/libsfml-graphics-s.a(RenderWindow.o):RenderWindow.cpp:(.text+0xae5): undefined reference to `glReadPixels@28'
/mingw/lib/libsfml-graphics-s.a(Shape.o):Shape.cpp:(.text+0x6b3): undefined reference to `glDisable@4'


Any ideas?  I dont think the other libraries (boost, SPK) are interfering, the problems all come from SFML libraries.
Title: Static library linking with mingw on windows
Post by: Laurent on March 17, 2010, 08:10:09 am
Which version of SFML are you using? Did you recompile it?
Title: Static library linking with mingw on windows
Post by: Trunks7j on March 17, 2010, 09:22:23 pm
SFML 1.5 stable release, and yes I did make clean before re-compiling.
Title: Static library linking with mingw on windows
Post by: Laurent on March 17, 2010, 11:17:29 pm
Quote
and yes I did make clean before re-compiling

Are you talking about your project, or SFML?
Title: Static library linking with mingw on windows
Post by: Mindiell on March 18, 2010, 08:27:37 am
Maybe because you kept something like 'SFML_DYNAMIC' ?
Title: Static library linking with mingw on windows
Post by: Trunks7j on March 19, 2010, 12:10:00 am
Quote from: "Laurent"
Quote
and yes I did make clean before re-compiling

Are you talking about your project, or SFML?


My project.  Why would I recompile SFML 1.5?  Should I compile the latest svn and try that?

Quote from: "Mindiell"
Maybe because you kept something like 'SFML_DYNAMIC' ?


Is that a preprocessor definition?   I don't have any of those set.
Title: Static library linking with mingw on windows
Post by: Mindiell on March 19, 2010, 07:10:06 am
I'm using Code::Blocks, it's a definition (-D I think ?)
Title: Static library linking with mingw on windows
Post by: Laurent on March 19, 2010, 08:19:04 am
He doesn't have to define SFML_DYNAMIC if he's switching to static libraries... ;)

Try to revert the order of libraries in the linker options
Code: [Select]
sfml-audio-s
sfml-graphics-s
sfml-window-s
sfml-system-s
Title: Static library linking with mingw on windows
Post by: Mindiell on March 19, 2010, 10:23:35 am
Quote from: "Mindiell"
Maybe because you kept something like 'SFML_DYNAMIC' ?
As I said, maybe he did use it, and do not need it anymore.
I don't know if defining SFML_DYNAMIC is "dangerous" while using statis libraries :)
Title: Static library linking with mingw on windows
Post by: Trunks7j on April 07, 2010, 03:31:12 am
Quote from: "Laurent"
He doesn't have to define SFML_DYNAMIC if he's switching to static libraries... ;)

Try to revert the order of libraries in the linker options
Code: [Select]
sfml-audio-s
sfml-graphics-s
sfml-window-s
sfml-system-s


This solved my issue, thank you.  However, its puzzling to me why that worked.  I would like to obtain a deeper understanding of the linker.

Also, the update of 1.6 fixed the audio delay bug on windows.  Thanks for your work!
Title: Static library linking with mingw on windows
Post by: Laurent on April 07, 2010, 08:12:17 am
Quote
This solved my issue, thank you. However, its puzzling to me why that worked. I would like to obtain a deeper understanding of the linker.

It's a mystery for me too.

Quote
Also, the update of 1.6 fixed the audio delay bug on windows.

:D
Which bug was that?
Title: Static library linking with mingw on windows
Post by: Trunks7j on April 08, 2010, 01:25:34 am
Quote from: Laurent
Quote

Quote
Also, the update of 1.6 fixed the audio delay bug on windows.

:D
Which bug was that?


I'd read about the bug on these forums before.  Basically, any time i would play a sound it would have about a 0.3 second delay before playing, which was obviously very noticable.  However I only had this problem on windows XP and windows 7, never on OSX.  But the problem went away with the 1.6 build of SFML.