当前位置:网站首页>【亲测可行】error while loading shared libraries的解决方案
【亲测可行】error while loading shared libraries的解决方案
2022-07-07 08:39:00 【Xminyang】
▚ 01 问题描述&分析
- 在
Linux中,编译或安装包时,常会遇到类似的问题:
error while loading shared libraries: libxxx.so: cannot open shared object file: No such file or directory
- 导致该问题的原因往往不是没有这个文件,而是没有配置好路径,所以编译时会因找不到该文件而报错。
本文假设未找到的库为
libmpfr.so.6,其绝对路径为/home/dabai/mpfr-4.0.2/lib
常用的解决方法有两个。

▚ 02 方法一:使用export命令
- 在终端使用
export命令来配置环境变量,但仅限于当前终端;对于其他终端窗口则需要重新使用export命令才起作用。 export配置环境变量的格式为:
export LD_LIBRARY_PATH=/home/dabai/mpfr-4.0.2/lib:$LD_LIBRARY_PATH
- 其中,
LD_LIBRARY_PATH是Linux环境变量名,该环境变量主要用于指定查找共享库(动态链接库)时除了默认路径之外的其他路径。

▚ 03 方法二:修改配置文件
- 修改配置文件,如
~/.bashrc或~/.bash_profile或/etc/profile。 - 其中,
普通用户可直接修改~/.bashrc或~/.bash_profile,因此,该修改仅对当前用户有效。 root用户可修改/etc/profile,且对所有用户都有效。
- 下面以修改
~/.bashrc文件为例:
vim ~/.bashrc
- 然后,在
.bashrc文件中添加如下内容:
export LD_LIBRARY_PATH=/home/dabai/mpfr-4.0.2/lib:$LD_LIBRARY_PATH
- 保存并退出后,在终端输入如下命令,以使上述命令生效:
source ~/.bashrc



边栏推荐
- 1324:【例6.6】整数区间
- P2788 math 1 - addition and subtraction
- ThreadLocal会用可不够
- TypeScript 接口继承
- The variables or functions declared in the header file cannot be recognized after importing other people's projects and adding the header file
- Gym installation pit records
- A small problem of bit field and symbol expansion
- P1223 排队接水/1319:【例6.1】排队接水
- 【推荐系统 01】Rechub
- 对word2vec的一些浅层理解
猜你喜欢

P2788 math 1 - addition and subtraction

Cluster task scheduling system lsf/sge/slurm/pbs based on HPC scenario

Adb 实用命令(网络包、日志、调优相关)

使用Tansformer分割三维腹部多器官--UNETR实战

555 circuit details

Five simple and practical daily development functions of chrome are explained in detail. Unlock quickly to improve your efficiency!

简单易修改的弹框组件

Use load_ decathlon_ Datalist (Monai) fast loading JSON data

2022年上半年5月网络工程师试题及答案

使用 load_decathlon_datalist (MONAI)快速加载JSON数据
随机推荐
Find the greatest common divisor and the least common multiple (C language)
Prototype and prototype chain
When do you usually get grades in the soft exam? Online pedaling?
How embedded engineers improve work efficiency
5个chrome简单实用的日常开发功能详解,赶快解锁让你提升更多效率!
[STM32] solution to the problem that SWD cannot recognize devices after STM32 burning program
软考信息处理技术员有哪些备考资料与方法?
宁愿把简单的问题说一百遍,也不把复杂的问题做一遍
P1223 queuing for water /1319: [example 6.1] queuing for water
Five simple and practical daily development functions of chrome are explained in detail. Unlock quickly to improve your efficiency!
Summary of router development knowledge
IDA中常见快捷键
Trajectory planning for multi robot systems: methods and Applications Overview reading notes
P1031 [NOIP2002 提高组] 均分纸牌
SQL Server 知识汇集11 : 约束
What are the test preparation materials and methods for soft exam information processing technicians?
高级软考(网络规划设计师)该如何备考?
ArrayList线程不安全和解决方案
深入分析ERC-4907协议的主要内容,思考此协议对NFT市场流动性意义!
施努卡:机器视觉定位技术 机器视觉定位原理