SFML community forums
Help => General => Topic started by: Grunz on March 11, 2012, 11:22:10 pm
-
System: Ubuntu 11.10 64 bit
cpu: AMD Phenom(tm) II X4 965 Processor × 4
I installed the 2.0 snapshot LaurentGomila-SFML-2de690f via cmake / Makefile. Had it make everything and did a "sudo make install"
This all looked good and /usr/local/lib/ now contains:
libsfml-audio.so libsfml-network.so.2.0 libsndfile.la
libsfml-audio.so.2 libsfml-system.so libsndfile.so
libsfml-audio.so.2.0 libsfml-system.so.2 libsndfile.so.1
libsfml-graphics.so libsfml-system.so.2.0 libsndfile.so.1.0.25
libsfml-graphics.so.2 libsfml-window.so pkgconfig
libsfml-graphics.so.2.0 libsfml-window.so.2 python2.6
libsfml-network.so libsfml-window.so.2.0 python2.7
libsfml-network.so.2 libsndfile.a site_ruby
also /usr/local/share/SFML/examples/ has:
ftp opengl pong shader sockets sound sound-capture voip window X11
However, if I try to compile an example myself like this:
gcc Window.cpp
/tmp/ccygC6cP.o: In function `main':
Window.cpp:(.text+0x3e): undefined reference to `std::allocator<char>::allocator()'
Window.cpp:(.text+0x53): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
... (more "undefined" errors)
/tmp/ccygC6cP.o:(.eh_frame+0x4b): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
So somehow "make" did know how to compile the examples, but I do not. :oops:
-
Use g++ instead of gcc. Also, you will need to throw in some flags like -lsfml-system and such.
Do make VERBOSE=1 to see what make is doing.
-
OK, digging recursively through make and cmake calling each other recursively it looks like using full path to SFML libraries is required. So
g++ -lsfml-window -lsfml-graphics -lsfml-system -lGLU -lGL -lSM -lICE -lX11 -lXext -lpthread -lrt -lXrandr -o window Window.cpp
compiles but linker fails. As mentioned already:g++ -c Window.cpp
does create the .o just fine without any extra flags.
Using full path like this:g++ -O3 Window.cpp -o window /usr/local/lib/libsfml-window.so.2.0 /usr/local/lib/libsfml-system.so.2.0 -lGLU -lGL -lSM -lICE -lX11 -lXext -lpthread -lrt -lXrandr
does work.
Checking "g++ -v" reveals that /usr/local/lib is not in the library path:
..
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.6.1/:/usr/lib/gcc/x86_64-linux-gnu/4.6.1/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.6.1/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.6.1/:/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../:/lib/:/usr/lib/
..
Would adding /usr/local/lib help avoid those unwieldy parameters? Does someone know how to do so?
-
-L/usr/local/lib
-
Yes, the -L does work, but only if I then also use the battalion of "-l" parameters like this:
g++ Window.cpp -L /usr/local/lib -lsfml-window -lsfml-graphics -lsfml-system -lGLU -lGL -lSM -lICE -lX11 -lXext -lpthread -lrt -lXrandr -o window
So, without -L, the linker can find openGL and the other stuff all by itself, but if I use it, it no longer can.
B.t.w. ,the man/info page for gcc does only mention the existence of the -L option. It is nowhere explained what it actually does. And I can call g++ -L "nonexisting path" and will get no errors from that. :(