Reputation: 111
I want to use SFML with C++ under Ubuntu OS. I create two debug/release shared Libarys with cmake (by this tutorial)
I can compile and link my test application without giving any information about a path. So I think everything is alright with the standard path
g++ -c main.cpp
g++ main.o -o sfml-app -lsfml-graphics -lsfml-window -lsfml-system
but when I start now my application with ./sfml-app it said
./sfml-app: error while loading shared libraries: libsfml-graphics.so.2: cannot open shared object file: No such file or directory
this confusing me. Because I think /usr/local/lib is the standard path and when I add this path during compiling
g++ main.o -o sfml-app -L /usr/local/lib -lsfml-graphics -lsfml-window -lsfml-system
it works. But it should work also without giving information with -L
So what could be the Problem? I have made this before reinstalling Ubuntu. And on my old system it works well, can start my application by ./ terminal and also double clicking.
when I add in the console
export LD_LIBRARY_PATH=$PATH:/usr/local/lib
I can start the application from the console. but only in the specific one. I want the application starts always also by double click (not only from terminal). How can I add the Libary "systemwide" ?
Upvotes: 2
Views: 1382
Reputation: 3530
You need to add /usr/local/lib
to a file in /etc/ld.so.conf.d/
and then call ldconfig
to rebuild its cache.
One way of doing it:
sudo sh -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/usrlocal'
sudo ldconfig
Then you should be able to compile without -L /usr/local/lib
nor use export LD_LIBRARY_PATH=$PATH:/usr/local/lib
.
Upvotes: 4