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

Author Topic: SFML 1.6 Linking problem with Code::Blocks [on Windows 7]  (Read 1864 times)

0 Members and 1 Guest are viewing this topic.

JoOber

  • Newbie
  • *
  • Posts: 2
    • View Profile
SFML 1.6 Linking problem with Code::Blocks [on Windows 7]
« on: January 28, 2012, 07:15:21 pm »
First few lines of the code (rest is identical to here):

Code: [Select]
#include <SFML/Audio.hpp>
 #include <SFML/Graphics.hpp>
 #include <SFML/System.hpp>

 int main()
 {
     sf::Clock Clock;

     // Create the main window
     sf::RenderWindow App(sf::VideoMode(800, 600), "SFML window");

     // Load a sprite to display
     sf::Image Image;

// [...]


other linker options:
-lsfml-audio
-lsfml-graphics
-lsfml-system

defines:
SFML_DYNAMIC

Clock, RenderWindow and Image link fine, however VideoMode (and all Window things which are not included in the above part) don't:

Code: [Select]
obj\Debug\main.o||In function `main':|
[...]\FirstSFML\main.cpp|10|undefined reference to `_imp___ZN2sf9VideoModeC1Ejjj'|
[...]\FirstSFML\main.cpp|41|undefined reference to `_imp___ZN2sf6Window5CloseEv'|
[...]\FirstSFML\main.cpp|37|undefined reference to `_imp___ZN2sf6Window8GetEventERNS_5EventE'|
[...]\FirstSFML\main.cpp|54|undefined reference to `_imp___ZN2sf6Window7DisplayEv'|
[...]\FirstSFML\main.cpp|33|undefined reference to `_imp___ZNK2sf6Window8IsOpenedEv'|
||=== Build finished: 5 errors, 0 warnings ===|


Statically linking doesn't work either.

I also tried linking with only the Clock (as in here) and linking works. If I link statically I can run the binary fine, if I try linking dynamically it aborts because of the missing dll.
My PATH includes "[...]\SFML-1.6\lib" and "[...]\SFML-1.6\extlibs" which are the directories where the dll's lie (I have double checked by navigating there). Both are also included in the linker search directories in the global compiler settings.
When moving the dll to another folder in PATH, the dynamically linked binary runs fine too.

JoOber

  • Newbie
  • *
  • Posts: 2
    • View Profile
SFML 1.6 Linking problem with Code::Blocks [on Windows 7]
« Reply #1 on: January 28, 2012, 07:30:07 pm »
Allright, I have resolved the problem by also adding
-lsfml-window

to the other linker options. Why is it needed here if I don't have to add SFML/Window?




PS: I have also noticed that extlibs does not contain any dlls and have removed it from PATH and from the linker search directories.

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
SFML 1.6 Linking problem with Code::Blocks [on Windows 7]
« Reply #2 on: January 28, 2012, 07:48:38 pm »
RenderWindow is a combination of Window and RenderTarget, so it requires both libraries.