C++ - shared library liblog4cpp.so.4 not found - c++

I tried to run a program that requires log4cpp,
I got following error when I try to run the program
error while loading shared libraries: liblog4cpp.so.4: cannot open shared object file: No such file or directory
I have set the library path in $LD_LIBRARY_PATH and these are the files in my /usr/local/lib directory:
liblog4cpp.a
liblog4cpp.so
liblog4cpp.so.5.0.6
liblog4cpp.la
liblog4cpp.so.5
pkgconfig
What could be the problem here ?
Thanks!

Use
ldd [program name]
so see what's actually loaded (assuming you are on a Unix system since you use LD_LIBRARY_PATH).

Related

Problems with GLEW

I have a problem with GLEW Library, I have a Linux system and I compiled a program with GLFW and GLEW but if I start my program it causes problems.
It outputs this:
./Test: error while loading shared libraries: libGLEW.so.2.0: cannot open shared object file: No such file or directory
I wrote a bash script with following code:
#!/bin/sh
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/Dokumente/Libraries/glfw-3.2.1-build/src/libglfw.so.3:~/Dokumente/Libraries/glew-2.0.0/lib/libGLEW.so.2.0
export LD_LIBRARY_PATH
./Test
But it doesn't work. It outputs the same error and I am sure the path is right
What can I do?
You can also allow loading of .so's from the same folder the executable is at "Windows Style" by setting the rpath with patchelf:
patchelf --set-rpath '$ORIGIN' your_program_binary
If you want to do this is up to you, of course. ;)
I have just solved the problem:
I put all Libraries into /usr/local/lib and change the LD_LIBRARY_PATH to this

Error while loading shared libraries: libboost_iostreams.so.1.59.0: cannot open shared object file: No such file or directory

I am running a C++ executable on ubuntu. The executable links into some boost libraries.
This is the output when I attempt to run the binary:
Error while loading shared libraries: libboost_iostreams.so.1.59.0: cannot open shared object file: No such file or directory
What should be the future coarse of action i should take to remove this error.
Let's assume your library is being exist but not in standard paths and you're getting this error while running a binary. In this case you could try to set the LD_LIBRARY_PATH environment variable to point to the directory where the library is located. Then the loader will search for the library in the given path.
export LD_LIBRARY_PATH=/path/to/my/library
./run_my_binary

error while loading shared libraries: libSDL2_mixer-2.0.so.0: cannot open shared object file: No such file or directory on Raspberry Pi

I'm writing a small program using c++. It compiles right, but at execution time it displays this message:
error while loading shared libraries: libSDL2_mixer-2.0.so.0: cannot open shared object file: No such file or directory
I've installed this library and I see the file libSDL2_mixer-2.0.so.0 in folder '/usr/local/lib'
Any idea?
Adding "export LD_LIBRARY_PATH=/usr/local/lib" in ~/.bashrc (at the end), as suggested here How to set the environmental variable LD_LIBRARY_PATH in linux.
Thanks

libSDL2-2.0.so.0: cannot open shared object file

I'm trying to build the SDL library from the source code. I've downloaded the compressed file (i.e. SDL2-2.0.3.tar.gz) and extracted it. I don't want to install the files in /usr/local. According to this link, I need to change the configure
The last command says "sudo" so we can write it to /usr/local (by
default). You can change this to a different location with the
--prefix option to the configure script. In fact, there are a LOT of good options you can use with configure! Be sure to check out its
--help option for details.
This is what I've done.
mkdir build
cd build
../configure
make
sudo make install
In install folder that I've created are the following files
share
lib
include
bin
Now I would like to run the test files. I've picked this testatomic.c and this is the command line
gcc testatomic.c -o test -I/home/xxxx/Desktop/SDL2-2.0.3/install/include/SDL2 -L/home/xxxx/Desktop/SDL2-2.0.3/install/lib -lSDL2 -lSDL2main
I get this error
error while loading shared libraries: libSDL2-2.0.so.0: cannot open shared object file: No such file or directory
In lib, these are the files
Where is the shared object file?
You're getting error when running resulting program because system's dynamic linker cannot find required library. Program requires libSDL2-2.0.so.0, linker looks for it in system-defined directories (/lib, /usr/lib, ..., - defined in /etc/ld.so.conf), but finds none - hence an error.
To inform linker where you want it to look for libraries, you can define LD_LIBRARY_PATH environment variable, e.g. in your case:
export LD_LIBRARY_PATH="$HOME/Desktop/SDL2-2.0.3/install/lib"
./test
Other ways is installing libraries in standard location, defining LD_LIBRARY_PATH in your .bashrc (or whatever shell you use), or using rpath, e.g. adding -Wl,-rpath=$HOME/Desktop/SDL2-2.0.3/install/lib at the end of your compilation line.
I was able to fix this problem with:
sudo apt install libsdl2-dev
I too had:
./01_hello_SDL: error while loading shared libraries: libSDL2-2.0.so.0: cannot open shared object file: No such file or directory
as a result of compiling the first C++ program (using the SDL headers) as part of the Lazy Foo tutorial. I found out that libSDL2-2.0.so.0 was just using the find command in the GUI. It turned out to be in /usr/local/lib
Then in terminal I typed:
export LD_LIBRARY_PATH="/usr/local/lib"
I checked the value of LD_LIBRARY_PATH using:
echo $LD_LIBRARY_PATH
I recompiled (don't know if that was necessary) and voila, it worked.

Running C++ programs remotely; error loading shared library

I'm a little confused as to what's happening here, when I'm our shared computer I can run our program, but when I ssh in from my house to restart it I get an exception
$ ./jsonparser
./jsonparser: error while loading shared libraries: libjansson.so.4: cannot open shared object file: No such file or directory
Is there some other way I should launch the app?
libjansson is installed to /usr/local/lib:
$ ls /usr/local/lib
libjansson.a libjansson.la libjansson.so libjansson.so.4 libjansson.so.4.6.0
Maybe /usr/local/lib is not in your Library pathg ( LD_LIBRARY_PATH I guess )? Or maybe there is a dependency for libjansson.so.4 is not resolved? By using ldd ./jsonparser ldd tries to load all dependent .so-file. Hopefully this will give you some more information about your issue.