running linux library file can not be found

      In order to increase the reusability and maintainability of the code, the operating system will generally introduce the concept of the library, the library is divided into static and dynamic libraries.

      Static library at compile time will be statically compiled into the program, run time is no longer dependent on the library;

      Dynamic library is the symbol table is compiled into the program, but the dynamic library program itself is not compiled into the program to go, so when the user program is running relies on dynamic libraries to do the right function.

      I can not find the root cause linux linux library file when the user runs the program does not find the dynamic library .so files in the specified directory.

This problem has many solutions.

  1. Library directories install libraries to the existing system:
    the system default path to the library to find some files, such as / lib /, / lib32 /, / lib64 /, lib /, lib32 /, libx86_64-linux-gnu /. Generally there will be / usr / local / lib and other directories.
    This approach has the characteristics of a global look, the drawback is that sometimes bad maintenance repository. Do not install the library also recommended to these directories, often because the version of the reason is easy to affect the stability of the entire system.

  2. Add programs to run the search path:
    Before running the program, the first to tell the compiler, if can not find the library, just to find my path below it.
    1) through the global configuration .bashrc:

    gedit ~/.bashrc
    #------------ 在末尾添加 -------------
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:你的库目录
    #------------ --------- -------------
    source ~/.bashrc
    
    1. Terminal configuration
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/libs
    

    I recommend this method to configure terminal, especially in the development phase of the program, but also easy to transplant using a modified method similar systems, when you want to migrate to the same computer, do not have to set up the database environment on another computer, directly to the program copy and past the library can add the path to run.

Guess you like

Origin blog.csdn.net/u012939880/article/details/95311259