SFML community forums
Help => General => Topic started by: P@u1 on March 06, 2011, 08:38:25 pm
-
Hi,
today I set up sfml and tried to use it with both eclipse (cdt) and visual studio 2010.
The clock example works fine (with both IDE's).
Then I wanted to try something with graphics.
In this forum I found this example:
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include<iostream>
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <iostream>
int main()
{
std::cout << "hallo";
sf::RenderWindow Game(sf::VideoMode(800, 600 ,32 ), "SFML BLANK WINDOW");
sf::Event Event;
while (Game.IsOpened())
{
while (Game.GetEvent(Event))
{
if (Event.Type == sf::Event::Closed)
Game.Close();
}
Game.Clear();
Game.Display();
}
return EXIT_SUCCESS;
}
}
unfortunately the render window is not being displayed, nore "hallo" is displayed.
Also I cant terminate the process from within eclipse (using the red square), but I must shoot the process up with windows task manager.
I'm using windows 7 64 bit.
The strange thing is that the problem occurs both with visual studio and eclipse so I think it's probably not up to my setup.
Here are some things I was not sure about in the setup:
-the order of the libraries in the linker settings (sfml-system-d,sfml-window-d, etc.)
-the preprocessor settings (SFML_DYNAMIC, SFML_STATIC, or just nothing).
Thanks in advance for any suggestions.
If you need further informations to help me just ask me.
Edit: im using an ati graphics card, I read somewhere that some ati drivers can cause problems with sfml, can this be the case here?
-
Edit: im using an ati graphics card, I read somewhere that some ati drivers can cause problems with sfml, can this be the case here?
Yes it is.
-
Is there some faq thread about this?
I have some questions to that:
How can I fix it?
(for example use another driver, but which one and will that lower my graphics experience in other games?)
And will other people with amd graphics cards whom i give my finished programs also have trouble running it?
-
A workaround is to link statically. The bug is going to be fixed in SFML 2.
You can find a lot of discussions concerning this topic when you use the forum search.
-
thx for you help.
Is there a guide about how to link statically? I used the search function but didn't find anything useful so far.
Edit:
Please help me, I dont have any clue how to link statically...
-
All you need to do is link to a static version of sfml libraries.
While you do something like sfml-system.lib now, the static version is commonly sfml-system-s.lib, the one you must link.
Its that simple, really! :) Check your libraries folder for some clarifying !
-
Is there a guide about how to link statically?
For stuff specific to Visual Studio, MSDN should be your first reference.
Walkthrough: Creating and Using a Static Library (http://msdn.microsoft.com/en-us/library/ms235627.aspx)
-
Thanks for you tips. I changed the entries to the ones with -s, but unfortunately I'm now getting lots of errors (compile or link).
**** Internal Builder is used for build ****
g++ -IC:\Program Files\SFML-1.6 g++\include -O0 -g3 -Wall -c -fmessage-length=0 -osrc\Hello World.o ..\src\Hello World.cpp
g++ -LC:\Program Files\SFML-1.6 g++\lib -oHello World.exe src\Hello World.o -lsfml-system-s-d -lsfml-window-s-d -lsfml-graphics-s-d -lsfml-audio-s-d
C:\Program Files\SFML-1.6 g++\lib/libsfml-window-s-d.a(Window.o): In function `Window':
D:/dev/sfml/sdk/SFML-1.6/src/SFML/Window/Window.cpp:55: undefined reference to `sf::Clock::Clock()'
D:/dev/sfml/sdk/SFML-1.6/src/SFML/Window/Window.cpp:55: undefined reference to `sf::Clock::Clock()'
D:/dev/sfml/sdk/SFML-1.6/src/SFML/Window/Window.cpp:70: undefined reference to `sf::Clock::Clock()'
D:/dev/sfml/sdk/SFML-1.6/src/SFML/Window/Window.cpp:70: undefined reference to `sf::Clock::Clock()'
D:/dev/sfml/sdk/SFML-1.6/src/SFML/Window/Window.cpp:85: undefined reference to `sf::Clock::Clock()'
C:\Program Files\SFML-1.6 g++\lib/libsfml-window-s-d.a(Window.o):D:/dev/sfml/sdk/SFML-1.6/src/SFML/Window/Window.cpp:85: more undefined references to `sf::Clock::Clock()' follow
C:\Program Files\SFML-1.6 g++\lib/libsfml-window-s-d.a(Window.o):D:/dev/sfml/sdk/SFML-1.6/src/SFML/Window/Window.cpp:358: undefined reference to `sf::Clock::GetElapsedTime() const'
C:\Program Files\SFML-1.6 g++\lib/libsfml-window-s-d.a(Window.o):D:/dev/sfml/sdk/SFML-1.6/src/SFML/Window/Window.cpp:360: undefined reference to `sf::Sleep(float)'
and lot more (just the beginning)
It would be very nice if you can help me.
-
Are you linking to sfml-system-s.lib in release mode and sfml-system-s-d.lib in debug mode?
By the way, have you tried with Visual Studio? For C++, I personally would prefer it over Eclipse.
-
so far i only changed the entires for debug mode, i used
sfml-system-s-d
for debug mode and compile in debug mode.
I didn't try the static linking in visual studio so far, but with dynamic linking it didn't work.
Any more suggestions, please?
Edit:
I configured and trief release mode now,
there I still get error, hower just few, here is the complete output (from release mode):
**** Build of configuration Release for project Hello World ****
**** Internal Builder is used for build ****
g++ -IC:\Program Files\SFML-1.6 g++\include -O3 -Wall -c -fmessage-length=0 -osrc\Hello World.o ..\src\Hello World.cpp
g++ -LC:\Program Files\SFML-1.6 g++\lib -oHello World.exe src\Hello World.o -lsfml-system-s -lsfml-graphics-s -lsfml-window-s -lsfml-audio-s
C:\Program Files\SFML-1.6 g++\lib/libsfml-window-s.a(Window.o):Window.cpp:(.text+0x3c4): undefined reference to `sf::Clock::Reset()'
C:\Program Files\SFML-1.6 g++\lib/libsfml-window-s.a(Window.o):Window.cpp:(.text+0x496): undefined reference to `sf::Clock::GetElapsedTime() const'
C:\Program Files\SFML-1.6 g++\lib/libsfml-window-s.a(Window.o):Window.cpp:(.text+0x4a4): undefined reference to `sf::Clock::Reset()'
C:\Program Files\SFML-1.6 g++\lib/libsfml-window-s.a(Window.o):Window.cpp:(.text+0x4de): undefined reference to `sf::Clock::GetElapsedTime() const'
C:\Program Files\SFML-1.6 g++\lib/libsfml-window-s.a(Window.o):Window.cpp:(.text+0x508): undefined reference to `sf::Sleep(float)'
C:\Program Files\SFML-1.6 g++\lib/libsfml-window-s.a(Window.o):Window.cpp:(.text+0xde1): undefined reference to `sf::Clock::Clock()'
C:\Program Files\SFML-1.6 g++\lib/libsfml-window-s.a(Window.o):Window.cpp:(.text+0x10cd): undefined reference to `sf::Clock::Clock()'
C:\Program Files\SFML-1.6 g++\lib/libsfml-window-s.a(Window.o):Window.cpp:(.text+0x1375): undefined reference to `sf::Clock::Clock()'
C:\Program Files\SFML-1.6 g++\lib/libsfml-window-s.a(Window.o):Window.cpp:(.text+0x1619): undefined reference to `sf::Clock::Clock()'
C:\Program Files\SFML-1.6 g++\lib/libsfml-window-s.a(Window.o):Window.cpp:(.text+0x188d): undefined reference to `sf::Clock::Clock()'
C:\Program Files\SFML-1.6 g++\lib/libsfml-window-s.a(Window.o):Window.cpp:(.text+0x1b01): more undefined references to `sf::Clock::Clock()' follow
collect2: ld returned 1 exit status
Build error occurred, build is stopped
Time consumed: 1519 ms.
please help :P
-
From the tutorial:
When linking to multiple SFML libraries, make sure you link them in the right order, as it's important for MinGW. The rule is the following : if library XXX depends on (uses) library YYY, put XXX first and then YYY. An exemple with SFML : sfml-graphics depends on sfml-window, and sfml-window depends an sfml-system. The link options would be as follows :
-lsfml-graphics
-lsfml-window
-lsfml-system
-
THX!
its working now