Error while loading shared libraries: lib *. So: cannot open shared object file: no such file or directory
Error while loading shared libraries: lib *. So: cannot open shared object file: no such file or directory
————————————————————————————————————————————————-
First of all, this topic is a bit long, but it well reflects the problems encountered.
In the article “how to generate two-dimensional code with C code”, Xiaobian also shows you how to compile QRcode correctly_ Test program, run the error problem. Let’s talk about it this time.
At that time, the terminal manual./running program error prompt./QRcode_ test: error while loading shared libraries: libzint.so .2.4: cannot open shared object file: No such file or directory
When running the program, you can’t find the information you need libzint.so Dynamic library. As we all know, the biggest difference between the dynamic library and the static library is that the static library is a static link, that is, the implementation of the static library is embedded into the program when the executable file is produced. Once the compilation is successful, the static library will have the value of existence. Even if the static library does not exist, the executable program can run; but the dynamic library is not the same It follows the dynamic link, that is to say, when compiling, you need to specify the path to find the so file link to compile, and when running, you also need to specify the corresponding path to find it. If it is running, the executable program will first go to the default system lib directory to find the so. If it cannot find it, it will report an error: error while loading shared libraries.
In the above paragraph, we talk about how to find the so file when the executable program is running, which is more general
The search paths of dynamic database are as follows
1. The dynamic library search path specified when compiling the object code;
2. Environment variable LD_ LIBRARY_ Path specified dynamic library search path
3. Configuration file/etc/ ld.so.conf The dynamic library search path specified in;
4. The default dynamic library search path is/lib/usr/lib.
Back to the problem of error while loading shared libraries when an executable program is running, in the article “how to generate two-dimensional code with C code”, we also talk about how to avoid this error and run the program. We use the “2. Environment variable LD” mentioned above_ LIBRARY_ Path specified dynamic library search path; “, that is, by setting LD_ LIBRARY_ Path, add the so path used by the current program to LD_ LIBRARY_ Path, so that when the program runs, to LD_ LIBRARY_ The so can be found by searching path. Of course, we have verified the correctness of this method before.
Look, there’s no problem with the program.
If we only introduce this method repeatedly, then the significance of this paper is not great. The greatest significance of this article is to tell readers that we can not set LD_ LIBRARY_ Pat can also run programs, so where should we start?This article mainly introduces, starting from compiling the program.
Here, I will first introduce the compilation options of GCC, but I will not elaborate here. If you are interested, you can learn about it through man GCC, or from the last article of blog [reprint] the parameters and commands commonly used in the use of GCC
Here, the compilation options we need to use are – WL, – rpath; mainly the letter L, not the number 1. -The rpath option tells GCC to write the path of the program to find so to the ELF file when compiling the link. The usage method is that GCC – o outapp *. C – lzint – WL, – rpath = “/ usr/local/lib” or GCC – o outapp *. C – lzint – WL, – rpath – WL, “/ usr/local/lib” are equivalent in function. As shown in the figure below:
As we can see from the figure, if the program is compiled successfully, it will no longer report error while loading shared libraries. Moreover, the biggest advantage of this method is that after the compilation is successful, the program can run without any settings. Of course, the – rpath parameter passed during compilation must be correct. This method is very useful, especially in cross compiling executable programs of embedded devices. Readers can try it for themselves.
posted @
2016-10-30 01:01
Mr.Recan Reading(
…) comments(
…)
edit
Collection
Read More:
- ./popins2: error while loading shared libraries: libbifrost.so: cannot open shared object file: No such file or directory
- [Solved] ./my_cmake_exe: error while loading shared libraries: libswresample.so.4: cannot open shared object file: No such file or directory
- [Solved] error while loading shared libraries: libopencv_highgui.so.3.4: cannot open shared object file…
- [619]libgtk-3.so.0 or libXt.so.6: cannot open shared object file: No such file or directory
- [Solved] import mxnet Error: OSError: libcudart.so.8.0: cannot open shared object file: No such file or directory
- [Solved] import cv2 Error: ImportError: libGL.so.1: cannot open shared object file: No such file or directory
- [Samtools] Run error: error while loading shared libraries: libcrypto.so.1.0.0 or libncurses.so.5 or libtinfow.so.5
- [Solved] curl error while loading shared libraries libcrypto.so.1.0.0
- DM Install Error: error while loading shared libraries: libdmnsort.so:
- ffmpeg:error while loading shared libraries: libopenh264.so.5
- [Solved] fatal error C1083: Could Not Open Unable to open include file:“stdint.h”: No such file or directory
- [Solved] java.lang.UnsatisfiedLinkError: dlopen failed: /lib/arm64/libc++_shared.so not found
- [Solved] mongodb Install Error: mongod: error while loading shared libraries
- [Solved] ERROR: Could not open requirements file: [Errno 2] No such file or directory : ‘requirments.txt‘
- [Solved] open failed: ENOENT (No such file or directory)
- Keil Compile Error: ..\OBJ\USART.axf: error: L6002U: Could not open file ..\obj\sys.o: No such file or directory
- VSCode Unable to find custom header file directory: fatal error: no such file or directory
- [Solved] fatal error C1083: Cannot open included files: “stdafx.h”: No such file or directory
- [Solved] fatal error: Eigen/Geometry: No such file or directory
- [Solved] 1.fatal error: NvInfer.h: No such file or directory