Error: loading shared libraries: cannot open shared object file: No such file or directory

Error : loading shared libraries: cannot open shared object file: No such file or directory

1. Problem Description:

The program s needs the support of Library L1 and Library L2 to run Library L1/L2 after installation, when executing software s, Library L2 shared object cannot be loaded, prompting that the file or path does not exist

**2. Solution:**

When the library is dynamic library, you need to indicate the path of the dynamic library for the operating system when running the program s.

2.1 determine the path of Library :
$ sudo find/-name library_name.so
2.2 determine whether the dynamic library path exists in the environment variable (ld_library_path) 
$ echo $LD_LIBRARY_PATH 
2.3 assign the dynamic library path to the environment variable (ld_library_path)
$ LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/the/lib
$ export LD_LIBRARY_PATH

You can run the program.

expand:

**1. Library files in linux System: * *
library is a collection of precompiled code segments called functions. Libraries contain common functions that together form a package called a library. Functions are blocks of code that are reused throughout the program. Calling these code fragments repeatedly in the program can save time. You can avoid rewriting code multiple times. For programmers, libraries provide reusable functions, data structures, classes, and so on.

Libraries are not executable, which is the key difference between processes and applications. Libraries work at run time or compile time. In C programming language, there are two types of Libraries: dynamic library and static library.

**Dynamic and static libraries: * *
dynamic or shared libraries appear as independent files other than executable program files. Therefore, the program only needs one copy of the dynamic/shared library file at run time. The static libraries are locked in the program.

**2. linux system environment variables: * *
environment variables and shell variables:

Environment variables are managed by the shell. The difference between environment variables and regular shell variables is that shell variables are local variables of specific instances of shell, such as shell scripts, while environment variables are “inherited” by any program you start, including another shell. In other words, the new process obtains copies of its own variables. It can read and modify these variables and pass them to its child processes in turn. In fact, every UNIX process (not just shell) passes its environment variables to its child processes.

Environment variables are globally available in programs and their subroutines. Shell variables are only available in the current shell. Environment variables like $shell are valid system wide. In the current bash shell, $bash points to the execution path of bash, while $shell points to the shell (its value may be the same) defined as Default.

#Define the shell variable VAR and its value
[biocodee@localhost ~]$ VAR="This is a variable"
[biocodee@localhost ~]$ echo $VAR
This is a variable
# See if the shell variable exists in the environment variable env
[biocodee@localhost ~]$ env | grep VAR
# Convert a shell variable to an environment variable
[biocodee@localhost ~]$ export VAR
[biocodee@localhost ~]$ env | grep VAR
VAR=This is a variable

Read More: