ldd can’t find library
I’ve already read this, this and this. I’ve installed OpenCV in a costum path /home/luca/ParallelOpenCV/install_icpc/lib , where there is libopencv_core.so :
luca@jarvis:~$ ldd /home/luca/ParallelOpenCV/install_icpc/lib/libopencv_core.so linux-vdso.so.1 => (0x00007ffccb389000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f46af719000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f46af410000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f46af1f2000) librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f46aefea000) libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f46aedd0000) libimf.so => /opt/intel/compilers_and_libraries_2017.1.132/linux/compiler/lib/intel64/libimf.so (0x00007f46ae8e3000) libsvml.so => /opt/intel/compilers_and_libraries_2017.1.132/linux/compiler/lib/intel64/libsvml.so (0x00007f46ad9d8000) libirng.so => /opt/intel/compilers_and_libraries_2017.1.132/linux/compiler/lib/intel64/libirng.so (0x00007f46ad663000) libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f46ad2e0000) libiomp5.so => /opt/intel/compilers_and_libraries_2017.1.132/linux/compiler/lib/intel64/libiomp5.so (0x00007f46acf3d000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f46acd27000) libintlc.so.5 => /opt/intel/compilers_and_libraries_2017.1.132/linux/compiler/lib/intel64/libintlc.so.5 (0x00007f46acabc000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f46ac6f3000) /lib64/ld-linux-x86-64.so.2 (0x000055f67574e000)
luca@jarvis:~$ ldd libopencv_core.so ldd: ./libopencv_core.so: No such file or directory
ldd can’t find library in LD_LIBRARY_PATH
I’m trying to get a system up and running, and am having problems with the OpenMotif shared libraries. I have their directory in LD_LIBRARY_PATH, but it still can’t find them. Here’s an example:
[root@intrepid netcool]# ldd /opt/netcool/omnibus/platform/linux2x86/bin/nco_* |grep 'not found' libXm.so.3 => not found libXpm.so.4 => not found libXm.so.3 => not found libXm.so.3 => not found libXpm.so.4 => not found libXm.so.3 => not found libXm.so.3 => not found libXm.so.3 => not found libXm.so.3 => not found [root@intrepid netcool]# find /usr/ -name libXm.so.3 /usr/lib64/libXm.so.3 [root@intrepid netcool]# find /usr/ -name libXpm.so.4 /usr/lib64/libXpm.so.4 [root@intrepid netcool]# echo $LD_LIBRARY_PATH /opt/netcool/omnibus//platform/linux2x86/lib/:/opt/netcool//platform/linux2x86/lib/:/usr/lib/:/usr/lib64/
I’m probably doing something stupid, but I can’t think of anything else to try. EDIT: To answer a couple of the questions asked below:
[root@intrepid netcool]# export LD_LIBRARY_PATH [root@intrepid netcool]# ldd /opt/netcool/omnibus/platform/linux2x86/bin/nco_* |grep 'not found' libXm.so.3 => not found libXpm.so.4 => not found libXm.so.3 => not found libXm.so.3 => not found libXpm.so.4 => not found libXm.so.3 => not found libXm.so.3 => not found libXm.so.3 => not found libXm.so.3 => not found [root@intrepid netcool]# ldconfig [root@intrepid netcool]# ldd /opt/netcool/omnibus/platform/linux2x86/bin/nco_* |grep 'not found' libXm.so.3 => not found libXpm.so.4 => not found libXm.so.3 => not found libXm.so.3 => not found libXpm.so.4 => not found libXm.so.3 => not found libXm.so.3 => not found libXm.so.3 => not found libXm.so.3 => not found
# ./bin/nco_xigen /opt/netcool//omnibus/platform/linux2x86/bin/nco_xigen: error while loading shared libraries: libXm.so.3: wrong ELF class: ELFCLASS64
ld64.so present in ldd, missing at runtime
I am compiling some code, and for various reasons I’m doing it statically. On my Ubuntu 12.04 / gcc 4.6.3 machine it compiles executes fine, and is fully static:
> ldd mycode not a dynamic executable
So far so good. But I also need to run it on another machine, a Scientific Linux 5 system, running gcc 4.5.3. For some reason here, ldd has some dynamic libs left over:
> ldd mycode linux-vdso.so.1 => (0x00007fffd75fd000) libstdc++.so.6 => /usr/local/swift/gcc-4.5.3/lib64/libstdc++.so.6 (0x00002b4bafab2000) libm.so.6 => /lib64/libm.so.6 (0x000000398ca00000) libc.so.6 => /lib64/libc.so.6 (0x000000398c600000) /lib/ld64.so.1 => /lib64/ld-linux-x86-64.so.2 (0x000000398c200000) libgcc_s.so.1 => /usr/local/swift/gcc-4.5.3/lib64/libgcc_s.so.1 (0x00002b4bafdb8000)
Which is, in itself, fine. The code compiles and links OK, and as you can see from ldd, all the dependencies are resolved. However, when I try to execute it on the SL machine, it fails:
> ./mycode /lib/ld64.so.1: bad ELF interpreter: No such file or directory
As far as I can see therefore, at execute time for some reason the /lib/ld64.so.1 => /lib64/ld-linux-x86-64.so.2 link is not being resolved, even though ldd does it. Of course, on machines where I have root access I can solve this by making a sym link from ld-linux-x84..blah to /lib/ld64.so.1 but this is a rather pants solution and I can’t apply it to our cluster. If I compile the whole thing dynamically it works fine, but this means installing all the 3rd party libraries I’m compiling against on a bunch of machines which I wanted to avoid. Finally, all the dependencies against which I compile are also used by another project, also compiled with cmake, and in that case I have no problem, and ldd actually lists the /lib64/ld-linux. blah direct, not a call to /lib/ld64.so. So — why is this happening? Why can I compile and link the code OK, ldd it OK, and yet not execute it? Any ideas would be gratefully received!
Linux — SO file not found
I have a program which requires liblog4cpp installed to run. Now, I want the program to run on another machine without liblog4cpp . So I just find the log4cpp.so and move it to the same directory of my program. But at running error reported:
error while loading shared libraries: liblog4cpp.so.4: cannot open shared object file: No such file or directory
6 Answers 6
In addition to what others are suggesting, consider adding the file to the dynamic linker’s cache. You can do it like this:
ldconfig -l /path/to/lib/liblog4.so.4
To add it to the loader’s cache use the following command: ldconfig
Then in order to verify that it was correctly added, run this:
Check your LD_LIBRARY_PATH environment variable. One of the directories on the path should point to the location of your log4cpp.so file; also the linux command ldd is handy for determining which shared object libraries are being used in your executable. The syntax is ldd .
assuming that the path where the .so file/s is available is /path you can also avoid to export an environment variable and just use
LD_LIBRARY_PATH=/path ./myProgram
beware the fact that if you do:
export LD_LIBRARY_PATH=/path
you are resetting LD_LIBRARY_PATH to a single value /path and losing anything you added before to this environment variable. If you want to add a value without losing the previous ones
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path
In the rc script from where you are launching your program, you should set the LD_LIBRARAY_PATH before launching the application. Remember, the .so are the shared libraries, it is required at the run time to link. Thus, it should be available in the standard path like /usr/lib before launching. In case it is not copied in the standard path like /usr/lib then specify the path by using the following.
export LD_LIBRARY_PATH=:$(LD_LIBRARY_PATH)
Ideally, I would have placed this .so in the standard path like /usr/lib. If it is installed in the standard path, then there is no need to set the above path. Remember, to make your program better, put the new path in ldconfig.conf.
You can debug such errors by using the following.
to know the so dependencies
For further, check the below link.
ldd says library isn’t found by compile completes successfully
I am attempting to compile project. It compiles successfully. My make command exits with a status code of 0 and there are no errors displayed. However, the project is not working, and when I run ldd -d
>ldd -d output_file.so linux-gate.so.1 => (0xf77e0000) libvstdlib_srv.so => not found libtier0_srv.so => not found libm.so.6 => /lib/libm.so.6 (0xf7760000) libdl.so.2 => /lib/libdl.so.2 (0xf775b000) libc.so.6 => /lib/libc.so.6 (0xf75a9000) /lib/ld-linux.so.2 (0x46e4a000) undefined symbol: pfVectorNormalize (output_file.so) undefined symbol: _Z12VectorAnglesRK6VectorR6QAngle (output_file.so) undefined symbol: pfSqrt (output_file.so) undefined symbol: __cxa_guard_acquire (output_file.so) undefined symbol: __cxa_guard_release (output_file.so) undefined symbol: _Z6ConMsgPKcz (output_file.so) undefined symbol: Warning (output_file.so) undefined symbol: __dynamic_cast (output_file.so) undefined symbol: _Z11ConColorMsgRK5ColorPKcz (output_file.so) undefined symbol: Error (output_file.so) undefined symbol: AssertValidStringPtr (output_file.so) undefined symbol: _AssertValidWritePtr (output_file.so) undefined symbol: _AssertValidReadPtr (output_file.so) undefined symbol: _ZTVN10__cxxabiv121__vmi_class_type_infoE (output_file.so) undefined symbol: _ZTVN10__cxxabiv120__si_class_type_infoE (output_file.so) undefined symbol: _ZTVN10__cxxabiv117__class_type_infoE (output_file.so) undefined symbol: __gxx_personality_v0 (output_file.so)
. lrwxrwxrwx 1 Andy Andy 62 May 2 12:30 libtier0_srv.so -> /home/dev/sdks/hl2sdk-ob-valve/lib/linux/libtier0_srv.so lrwxrwxrwx 1 Andy Andy 64 May 2 12:30 libvstdlib_srv.so -> /home/dev/sdks/hl2sdk-ob-valve/lib/linux/libvstdlib_srv.so -rw-r--r-- 1 Andy Andy 5444 May 2 11:53 Makefile .
The gcc command being run is gcc -I/home/dev/sdks/hl2sdk-ob-valve/public/game/server -I. -I.. -ICEntity -Isdk -I/home/dev/project1/hl2sdk-ob-valve/public -I/home/dev/sdks/hl2sdk-ob-valve/public/engine -I/home/dev/sdks/hl2sdk-ob-valve/public/tier0 -I/home/dev/sdks/hl2sdk-ob-valve/public/tier1 -I/home/dev/sdks/hl2sdk-ob-valve/public/mathlib -I/home/dev/project1/mmsource-central/core -I/home/dev/project1/mmsource-central/core/sourcehook -I/home/dev/project1/sourcemod-central/public -I/home/dev/project1/sourcemod-central/public/sourcepawn -I/home/dev/project1/sourcemod-central/core project1_output/sdk/smsdk_ext.o project1_output/extension.o project1_output/CTrackingProjectile.o project1_output/CSentryRocket.o project1_output/CProjectileRocket.o project1_output/CProjectileArrow.o project1_output/CProjectileFlare.o project1_output/CProjectilePipe.o project1_output/CProjectileSyringe.o project1_output/CEntity/CEntity.o project1_output/CEntity/CEntityManager.o project1_output/CEntity/CPlayer.o /home/dev/project1/hl2sdk-ob-valve/lib/linux/tier1_i486.a libvstdlib_srv.so libtier0_srv.so -m32 -lm -ldl -static-libgcc -shared -o project1_output/output_file.so My questions are: 1.) Why are those two libraries not found even though they are symlinked? 2.) The undefined symbols are part of the mathlib package, which is included in the gcc command. -I/home/dev/sdks/hl2sdk-ob-valve/public/mathlib Why would these be undefined, despite being included? c++ is not my language of choice and I know enough about Makefiles to be dangerous, but not really to fix anything, so I apologize if this is not enough information. I can provide more as needed.