当前位置:网站首页>[pro test feasible] error while loading shared libraries solution

[pro test feasible] error while loading shared libraries solution

2022-07-07 10:43:00 Xminyang

▚ 01  Problem description & analysis


  • stay Linux in , When compiling or installing packages , We often encounter similar problems :
error while loading shared libraries: libxxx.so: cannot open shared object file: No such file or directory
  • The reason for this problem is often not the absence of this file , Instead, the path is not configured , Therefore, an error will be reported when compiling because the file cannot be found .

This article assumes that the library not found is libmpfr.so.6, The absolute path is /home/dabai/mpfr-4.0.2/lib
There are two common solutions .

 Insert picture description here


▚ 02  Method 1 : Use export command


  • Terminal use export Command to configure environment variables , But only limited to the current terminal ; For other terminal windows, you need to reuse export Orders work .
  • export The format of the configuration environment variable is :
export LD_LIBRARY_PATH=/home/dabai/mpfr-4.0.2/lib:$LD_LIBRARY_PATH
  • among ,LD_LIBRARY_PATH yes Linux Environment variable name , This environment variable is mainly used to specify the search of shared libraries ( Dynamic link library ) In addition to the default path .

 Insert picture description here


▚ 03  Method 2 : Modify the configuration file


  • Modify the configuration file , Such as ~/.bashrc or ~/.bash_profile or /etc/profile.
  • among , Ordinary users It can be modified directly ~/.bashrc or ~/.bash_profile, therefore , This modification is only valid for the current user .
  • root user Modifiable /etc/profile, And it is effective for all users .

  • Let's modify ~/.bashrc File as an example :
vim ~/.bashrc
  • then , stay .bashrc Add the following to the file :
export LD_LIBRARY_PATH=/home/dabai/mpfr-4.0.2/lib:$LD_LIBRARY_PATH
  • After saving and exiting , Enter the following command at the terminal , To give effect to the above order :
source ~/.bashrc






 Insert picture description here

 Insert picture description here

 Insert picture description here

原网站

版权声明
本文为[Xminyang]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207070839069076.html