SFML - Can't even compile tutorial code

Started by
12 comments, last by DejaimeNeto 10 years, 1 month ago

You probably need to include the SFML directory.
Something like this:


g++ -c main.cpp -I~SFML_INCLUDE_DIRECTORY_GOES_HERE~
//like in
g++ -c main.cpp -I/home/me/SFML/include

I'd personally use an IDE.

@edit

Yeah I did, and I running "make install" seemed to do it. Now I'm getting yet another error. I can now compile my code, but can't run it.


./main
./main: error while loading shared libraries: libsfml-window.so.2: cannot open shared object file: No such file or directory

If g++ is building your program successfully, but you can't find it, look if the main executable wasn't generated in a different directory. Using -o to specify a name, as in g++ main.cpp -o program.exe can help you locate it.

But this may be a linkage problem; linking statically will probably solve this.

Advertisement

The only other thing I can think of is maybe you would be missing the symbolic link from .so.2 to .so.2.1 somehow.

Edit: removed bit about ldconfig since you weren't grepping the file, so that shouldn't be the problem.

Ah, turns out I was using 1.6. Thanks!

Edit: I installed 2.1 using cmake and now I'm getting this error.


g++ main.cpp -lsfml-audio -lsfml-network -lsfml-graphics -lsfml-window -lsfml-system
main.cpp:1:27: fatal error: SFML/Window.hpp: No such file or directory
 #include <SFML/Window.hpp>

I really don't have the faintest idea what I'm doing, is there any reason installing this is so ridiculously difficult?

It's telling you it doesn't know where that header file is. You need to add a -L<include_directory> to your compile line so it knows where Window.hpp is. You have to provide paths to all such external headers and libs.

Not -L, -I (capital i).

-L is for specifying library paths.

My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)


./main: error while loading shared libraries: libsfml-window.so.2: cannot open shared object file: No such file or directory


Not -L, -I (capital i).

-L is for specifying library paths.

He has already fixed the include path problem. It looks like he just didn't copy the necessary files for the shared linking.

This topic is closed to new replies.

Advertisement