SFML community forums
Help => General => Topic started by: Kreshdev on September 27, 2011, 04:24:32 am
-
Greetings!
I am new to this site and I have followed many tutorials and searched before posting this to make sure that it wasn't already explained anywhere and it seems like it doesn't (or I just really suck at searching).
My problem is that when I try to compile a really simple script:
#include <SFML/Graphics.hpp>
int main()
{
// Create the main window
sf::RenderWindow App(sf::VideoMode(800, 600), "SFML window");
// Load a sprite to display
sf::Image Image;
if (!Image.LoadFromFile("cb.bmp"))
return EXIT_FAILURE;
sf::Sprite Sprite(Image);
// Start the game loop
while (App.IsOpened())
{
// Process events
sf::Event Event;
while (App.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
App.Close();
}
// Clear screen
App.Clear();
// Draw the sprite
App.Draw(Sprite);
// Update the window
App.Display();
}
return EXIT_SUCCESS;
}
, I am getting the following errors:
ld||cannot find -lsfml-system|
ld||cannot find -lsfml-audio|
ld||cannot find -lsfml-graphics|
ld||cannot find -lsfml-network|
ld||cannot find -lsfml-window|
ld||cannot find -lsfml-graphics-s|
ld||cannot find -lsfml-audio-s|
ld||cannot find -lsfml-window-s|
ld||cannot find -lsfml-network-s|
ld||cannot find -lsfml-system-s|
ld||cannot find -lsfml-graphics-s|
ld||cannot find -lsfml-audio-s|
ld||cannot find -lsfml-network-s|
ld||cannot find -lsfml-window-s|
ld||cannot find -lsfml-system-s|
||=== Build finished: 15 errors, 0 warnings ===|
I have followed this tutorial (http://sfmlcoder.wordpress.com/2011/05/18/creating-a-first-sfml-project/) for the static version and I did everything as told in there. Could anyone please help me out as I feel like this is a really stupid error and I have been looking for a way to fix this issue for a few hours now and I am tired of searching... : /
-
It seems you didn't install the release shared version of SFML (ld||cannot find -lsfml-system) and the release static version (ld||cannot find -lsfml-system-s).
Moreover, it seems you are linking your project against BOTH of them; which is wrong. You should only link your project against one type of libraries.
On a side note it's recommended to use shared libraries instead of static libraries on Unix-like OSes. There are plenty of discussion about that on the Internet if you want to know why and how.
-
Hi!
You seem to be on Linux, am I right?
If so, you don't the "-lsfml-xyz" options, it's only for Windows, but you should link the libraries instead, in this order:
/usr/local/lib/libsfml-network.so
/usr/local/lib/libsfml-audio.so
/usr/local/lib/libsfml-graphics.so
/usr/local/lib/libsfml-window.so
/usr/local/lib/libsfml-system.so
-
If so, you don't the "-lsfml-xyz" options, it's only for Windows
Nope, you're wrong. :wink: g++crash course (http://homepages.gac.edu/~mc38/2001J/documentation/g++.html)
-
Yes, I am on Ubuntu. Could anyone please tell me exactly what to do because I am a bit confused. >.<
-
Install SFML to a standard path (/usr/lib or /usr/local/lib for example), don't use the static libraries (-s), and everything should be ok.
-
Alright, thank you. I will try that out and give you some news soon.
-
If so, you don't the "-lsfml-xyz" options, it's only for Windows
Nope, you're wrong. :wink: g++crash course (http://homepages.gac.edu/~mc38/2001J/documentation/g++.html)
Ok, thanks for the clarification.
What I meant is, the "-lsfml-xyz" directives are just ingored here. They just don't work for me, I had to set the libraries as I've listed them above.
So, Kreshdev, what I suggest is, if you're on Code::Blocks, delete the "-lsfml-*" stuff and set Project/ Build options/ Linker settings/ Link libraries to:
/usr/local/lib/libsfml-network.so
/usr/local/lib/libsfml-audio.so
/usr/local/lib/libsfml-graphics.so
/usr/local/lib/libsfml-window.so
/usr/local/lib/libsfml-system.so
These files are at "/usr/local/lib", at least, for me. You should check where these files are on your computer. They also might be at "/usr/lib", for example.
-
Is it normal if the library files are named, for example:
lsfml-audio.so.1.6
lsfml-etc.so.1.6 or should I rename them to have the .so extension only?
Because it keeps saying
/home/tristan/Code::Blocks/SFML/SFML/main.cpp|1|fatal error: SFML/Graphics.hpp: No such file or directory|
-
What I meant is, the "-lsfml-xyz" directives are just ingored here. They just don't work for me, I had to set the libraries as I've listed them above.
You must rather add /usr/local/lib to your linker search paths (see ldconfig).
Is it normal if the library files are named, for example:
lsfml-audio.so.1.6
lsfml-etc.so.1.6 or should I rename them to have the .so extension only?
Yes, there are also symbolic links:
sfml-audio.so -> sfml-audio.so.1.6
etc.
/home/tristan/Code::Blocks/SFML/SFML/main.cpp|1|fatal error: SFML/Graphics.hpp: No such file or directory|
This has nothing to do with the libraries, it's your compiler that can't find the headers.
-
I am still experiencing the "'SFML/Graphics.hpp' no such file or directory" issue.. any idea how to fix it?
-
Add the directory that contains the SFML headers to your compiler search paths.