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

Author Topic: Static library linking with mingw on windows  (Read 7317 times)

0 Members and 1 Guest are viewing this topic.

Trunks7j

  • Newbie
  • *
  • Posts: 15
    • View Profile
Static library linking with mingw on windows
« 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Static library linking with mingw on windows
« Reply #1 on: March 17, 2010, 08:10:09 am »
Which version of SFML are you using? Did you recompile it?
Laurent Gomila - SFML developer

Trunks7j

  • Newbie
  • *
  • Posts: 15
    • View Profile
Static library linking with mingw on windows
« Reply #2 on: March 17, 2010, 09:22:23 pm »
SFML 1.5 stable release, and yes I did make clean before re-compiling.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Static library linking with mingw on windows
« Reply #3 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?
Laurent Gomila - SFML developer

Mindiell

  • Hero Member
  • *****
  • Posts: 1261
    • ICQ Messenger - 41484135
    • View Profile
Static library linking with mingw on windows
« Reply #4 on: March 18, 2010, 08:27:37 am »
Maybe because you kept something like 'SFML_DYNAMIC' ?
Mindiell
----

Trunks7j

  • Newbie
  • *
  • Posts: 15
    • View Profile
Static library linking with mingw on windows
« Reply #5 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.

Mindiell

  • Hero Member
  • *****
  • Posts: 1261
    • ICQ Messenger - 41484135
    • View Profile
Static library linking with mingw on windows
« Reply #6 on: March 19, 2010, 07:10:06 am »
I'm using Code::Blocks, it's a definition (-D I think ?)
Mindiell
----

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Static library linking with mingw on windows
« Reply #7 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
Laurent Gomila - SFML developer

Mindiell

  • Hero Member
  • *****
  • Posts: 1261
    • ICQ Messenger - 41484135
    • View Profile
Static library linking with mingw on windows
« Reply #8 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 :)
Mindiell
----

Trunks7j

  • Newbie
  • *
  • Posts: 15
    • View Profile
Static library linking with mingw on windows
« Reply #9 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!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Static library linking with mingw on windows
« Reply #10 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?
Laurent Gomila - SFML developer

Trunks7j

  • Newbie
  • *
  • Posts: 15
    • View Profile
Static library linking with mingw on windows
« Reply #11 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.