After the compilation of cmakelist is completed, the error libopencv_world.so.4.5: cannot open shared object file: No such file or directory is reported.

Main problem:
Recently I was working on Hikvision SDK to call the camera, and found that the camera could not be called under Linux. It always prompted error code: 29, registration failed, and after recompiling, there was a problem that the dependent library could not be found.

1. Abnormal

After the dynamic library .so compiled by CmakeLists is moved to another location, it is prompted that the library's dependent library solution cannot be found. The error message is as follows:
Insert image description here
Insert image description here

OSError: libopencv_world.so.4.5: cannot open shared object file: No such file or directory

I compiled a library with opencv, including other libraries. When I ran it under the compiled path, it was normal. When I moved it to another location for deployment, this problem was prompted.

2.Solution

According to Baidu tips:
Insert image description here
Therefore, you only need to do one step:
reset the third-party libraries used after compilation into the environment variables:
Wen Xinyiyan said:
Set the correct LD_LIBRARY_PATH: When running the application, ensure that the directory where the dynamic library is located Add to the LD_LIBRARY_PATH environment variable. In this way, the runtime system can find and load the required dependent libraries:

export LD_LIBRARY_PATH=/path/to/libs:$LD_LIBRARY_PATH

For example, after I compiled the dynamic library, make installed all the dependent libraries I needed into the alg_lib folder. Therefore, I need to execute:

export LD_LIBRARY_PATH=/code//alglib/alg_lib/:$LD_LIBRARY_PATH

After you're done, you can run normally.

Another problem is that this temporary variable will become invalid after shutdown and restart, so we can add export statements in ~/.bashrc or ~/.bash_profile. The former is read once every time you log in and every time you open the shell, and the latter Read only once at login:

vim ~/.bashrc
export LD_LIBRARY_PATH=/code//alglib/alg_lib/:$LD_LIBRARY_PATH

My habit is to add it to ~/.bashrc. At the end of the file, you can use the following statement to make the settings take effect:

3.Other matters

If the Hikvision SDK fails to register with error code 29, check the SDK error coding specifications. Either the environment or the account and password are incorrect. Environmental problems are the most common.

Guess you like

Origin blog.csdn.net/llsplsp/article/details/134559149