Reputation: 121
I'm on Ubuntu 18.04, GCC 7.4
I created a test shared-library then copy it to /usr/local/lib/ The .so file has been created like this:
gcc -Wall -fPIC -c src/Test.cpp -o obj/Test.o
gcc -shared -Wl,-soname,libhztest.so -o bin/libhztest.so obj/*.o
sudo cp bin/libhztest.so /usr/local/lib/hazeltest/
sudo chmod 777 /usr/local/lib/hazeltest/
Then I created a test app and tried to run it and I get : error while loading shared libraries: libhztest.so: cannot open shared object file: No such file or directory
If I do export a proper LD_LIBRARY_PATH and it works but I prefer to use ldconfig
Unfortunately ldconfig doesn't seem to link my library even though the directory /usr/local/lib/ is well included in the /etc/ld.so.conf
Anyone could tell me why this doesn't work? Thanks
Upvotes: 3
Views: 8593
Reputation: 121
I finally get it running the command :
sudo ldconfig /usr/local/lib/hazeltest/
Upvotes: 3
Reputation: 51840
You need to copy it into /usr/local/lib/
, not /usr/local/lib/hazeltest/
. Either that, or add /usr/local/lib/hazeltest/
to /etc/ld.so.conf
. (Although I think you're supposed to add this in a new file in /etc/ld.so.conf.d/
instead, like /etc/ld.so.conf.d/hazeltest.conf
, so that you don't modify ld.so.conf directly which might be an auto-generated file).
Upvotes: 2