error while loading shared libraries:

created at 08-10-2021 views: 35


After sysbench is installed, the following problems occur when checking the sysbench version number sysbench --version:

/usr/local/sysbench/bin/sysbench: error while loading shared libraries: cannot open shared object file: No such file or directory


The installation directory of mysql is in /app/databases/mysql. MySQL has a lot of libraries under the lib directory. At this time, you need to add a line /app/database/mysql/lib under /etc/ and save it. ldconfig, the new library can be found when the program is running

The purpose of the ldconfig command is mainly to search for the sharable dynamic link library (format such as lib. so), and then create the connection and cache files required by the dynamic loader ( The cache file defaults to /etc/ This file saves a sorted list of dynamic link library names. In order to make the dynamic link library shared by the system, you need to run the dynamic link library management command ldconfig, which executes the program Stored in the /sbin directory.

ldconfig usually runs when the system starts, and when the user installs a new dynamic link library, you need to manually run this command.

ldconfig several points to note:

  1. Add things to /lib and /usr/lib, you don't need to modify /etc/, but you need to adjust ldconfig after finishing, otherwise the library will not be found.
  2. When adding things to the above two directories, be sure to modify /etc/, and then call ldconfig, otherwise it will not be found. For example, if you install a mysql to /usr/local/mysql, mysql has a lot of libraries under /usr/local/mysql/lib
  3. If you want to put lib outside of these two directories, but don't want to add things in /etc/ (or add things without permission). That's okay, that is, export a global variable LD_LIBRARY_PATH, and then when you run the program, you will find the library in this directory. Generally speaking, this is only a temporary solution, used when there is no permission or temporary need.
  4. These things done by ldconfig are all related to the time of running the program, and have nothing to do with the time of compiling. When compiling, you still need to add -L, so don't get confused.
  5. In short, no matter what changes are made to the library, it is best to ldconfig, otherwise there will be some unexpected results. It won't take too much time, but it will save a lot of things.
  6. Also, for example, the file header will contain information related to the library name (that is, it contains "", which can be viewed with the strings command), so only by modifying the file name to impersonate someone Recognized libraries (such as will not work. To this end, you can directly modify the configuration information in the Makefile of the compiled library and specify a special library name.
created at:08-10-2021
edited at: 08-10-2021: