The “ld_library_path” is basically an environment variable that assigns a path to the shared libraries. It is quite useful to execute the application based on a specific path in the system. An error “export ld_library_path” comes across during the relocation or execution of library files. To encounter this error, this guide will provide all possible solutions. The content that supported this article is as follows:
- Reason: Inappropriate Library Path
- Solution 1: Set the Correct Library Path
- Solution 2: Set Library Path Using bashrc Script
Let’s start the article.
Reason: Inappropriate Library Path
The LD_LIBRARY_PATH relocates built-in libraries while upgrading the installed application. And these libraries are stored in multiple locations. An inappropriate wrong path causes an error that does not locate the particular library.
Solution 1: Set the Correct Library Path
One of the best solutions is to specify the location of the path where the libraries are stored in the operating system “/usr/local/lib”. For instance, the export utility is used to set the environment variable and passed to child processes as below:
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
After setting the path of the environment variable “LD_LIBRARY_PATH”, you can verify the specific directory by executing below script:
$ echo $LD_LIBRARY_PATH
Let head over to the second solution.
Solution 2: Set Library Path Using bashrc Script
The bashrc is nothing but a bash script that is run when a user logs in. It is found in the home directory as a hidden file. You can give the library path where applications can easily be executable. To do so, execute the below script that specifies the path and store it in the “bashrc” script file:
$ echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib' >> ~/.bashrc
Check Environment Variable
To check the environment variables, execute the “GOPATH” environment variable with the “echo” script”:
$ echo $GOPATH
The output confirms the path of the workspace directory.
The error “export ld_library_path” occurs because the executable files are present in an inappropriate path. To encounter the specified error, set the environment variable to the “/usr/local/lib” directory. Additionally, you can set the library path using the bashrc bash script. This guide has covered possible solutions to resolve the “export ld_library_path” error.