当前位置:网站首页>【亲测可行】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
边栏推荐
- P2788 math 1 - addition and subtraction
- 移动端通过设置rem使页面内容及字体大小自动调整
- ThreadLocal is not enough
- [email protected] can help us get the log object quickly
- Talking about the return format in the log, encapsulation format handling, exception handling
- BigDecimal value comparison
- [actual combat] transformer architecture of the major medical segmentation challenges on the list --nnformer
- 中级软件评测师考什么
- What are the test preparation materials and methods for soft exam information processing technicians?
- MySQL insert data create trigger fill UUID field value
猜你喜欢
枪出惊龙,众“锁”周之
leetcode-304:二维区域和检索 - 矩阵不可变
How to prepare for the advanced soft test (network planning designer)?
Applet jump to H5, configure business domain name experience tutorial
CAS mechanism
[recommendation system 02] deepfm, youtubednn, DSSM, MMOE
打算参加安全方面工作,信息安全工程师怎么样,软考考试需要怎么准备?
Some superficial understanding of word2vec
1323:【例6.5】活动选择
MySQL insert data create trigger fill UUID field value
随机推荐
Common shortcut keys in IDA
Use load_ decathlon_ Datalist (Monai) fast loading JSON data
[牛客网刷题 Day6] JZ27 二叉树的镜像
使用U2-Net深层网络实现——证件照生成程序
P1031 [NOIP2002 提高组] 均分纸牌
ThreadLocal is not enough
1323: [example 6.5] activity selection
What does intermediate software evaluator test
555电路详解
高级软考(网络规划设计师)该如何备考?
Adb 实用命令(网络包、日志、调优相关)
2022.7.3DAY595
Prototype and prototype chain
Schnuka: machine vision positioning technology machine vision positioning principle
ADB utility commands (network package, log, tuning related)
路由器开发知识汇总
求方程ax^2+bx+c=0的根(C语言)
What are the test preparation materials and methods for soft exam information processing technicians?
打算参加安全方面工作,信息安全工程师怎么样,软考考试需要怎么准备?
深入理解Apache Hudi异步索引机制