环境:ubuntu 22.04 使用docker安装的oracle
操作:在使用gcc编译器时,链接动态库 -locci -lclntsh,设置环境变量不行之后,又加了(-L库文件路径),变成-locci可以,但是-lclntsh不行,报错如标题所示
(备注:如果你是两个文件都找不到的话,看看是不是root权限问题,因为docker的路径是默认root的;再或者你的 -L库文件路径 不正确)
解决问题:
1、查看文件详细信息
locate libclntsh.so
输出情况:
root@mrluo-virtual-machine:/home/mrluo# locate libclntsh.so
/var/lib/docker/overlay2/7d5a179cbd6d8abc77bc0d51040714ed6045d33851698f9c7c5779b46c93b478/merged/home/oracle/app/oracle/product/11.2.0/dbhome_2/inventory/Scripts/ext/lib/libclntsh.so.11.1
/var/lib/docker/overlay2/7d5a179cbd6d8abc77bc0d51040714ed6045d33851698f9c7c5779b46c93b478/merged/home/oracle/app/oracle/product/11.2.0/dbhome_2/inventory/backup/2014-08-23_05-45-12AM/Scripts/ext/lib/libclntsh.so.11.1
/var/lib/docker/overlay2/7d5a179cbd6d8abc77bc0d51040714ed6045d33851698f9c7c5779b46c93b478/merged/home/oracle/app/oracle/product/11.2.0/dbhome_2/lib/libclntsh.so
/var/lib/docker/overlay2/7d5a179cbd6d8abc77bc0d51040714ed6045d33851698f9c7c5779b46c93b478/merged/home/oracle/app/oracle/product/11.2.0/dbhome_2/lib/libclntsh.so.10.1
/var/lib/docker/overlay2/7d5a179cbd6d8abc77bc0d51040714ed6045d33851698f9c7c5779b46c93b478/merged/home/oracle/app/oracle/product/11.2.0/dbhome_2/lib/libclntsh.so.11.1
/var/lib/docker/overlay2/b105bb6cc6d953181ba0381d099635f99ec9dbe76c70637f10f350256ed0a599/diff/home/oracle/app/oracle/product/11.2.0/dbhome_2/inventory/Scripts/ext/lib/libclntsh.so.11.1
/var/lib/docker/overlay2/b105bb6cc6d953181ba0381d099635f99ec9dbe76c70637f10f350256ed0a599/diff/home/oracle/app/oracle/product/11.2.0/dbhome_2/inventory/backup/2014-08-23_05-45-12AM/Scripts/ext/lib/libclntsh.so.11.1
/var/lib/docker/overlay2/b105bb6cc6d953181ba0381d099635f99ec9dbe76c70637f10f350256ed0a599/diff/home/oracle/app/oracle/product/11.2.0/dbhome_2/lib/libclntsh.so
/var/lib/docker/overlay2/b105bb6cc6d953181ba0381d099635f99ec9dbe76c70637f10f350256ed0a599/diff/home/oracle/app/oracle/product/11.2.0/dbhome_2/lib/libclntsh.so.10.1
/var/lib/docker/overlay2/b105bb6cc6d953181ba0381d099635f99ec9dbe76c70637f10f350256ed0a599/diff/home/oracle/app/oracle/product/11.2.0/dbhome_2/lib/libclntsh.so.11.1
2、进入到相应文件里面
cd /var/lib/docker/overlay2/b105bb6cc6d953181ba0381d099635f99ec9dbe76c70637f10f350256ed0a599/diff/home/oracle/app/oracle/product/11.2.0/dbhome_2/lib
3、查看libclntsh的详细信息
root@mrluo-virtual-machine:/var/lib/docker/overlay2/b105bb6cc6d953181ba0381d099635f99ec9dbe76c70637f10f350256ed0a599/diff/home/oracle/app/oracle/product/11.2.0/dbhome_2/lib# ll | grep libclntsh
lrwxrwxrwx 1 500 500 69 8月 23 2014 libclntsh.so -> /home/oracle/app/oracle/product/11.2.0/dbhome_2/lib/libclntsh.so.11.1
lrwxrwxrwx 1 500 500 64 8月 23 2014 libclntsh.so.10.1 -> /home/oracle/app/oracle/product/11.2.0/dbhome_2/lib/libclntsh.so
-rwxr-xr-x 1 500 500 48725713 8月 23 2014 libclntsh.so.11.1*
这个时候发现问题就在这里,大家可以尝试用1、2、3的步骤看看能通过的-locci就会发现这里的两个软链接都是指向错误的,因为我们用了docker容器安装的oracle,所以路径就在docker里面,而不在默认路径下了
4、更改这里的两个软链接
先删除rm,后链接ln文章来源:https://www.toymoban.com/news/detail-621088.html
rm libclntsh.so
rm libclntsh.so.10.1
ln -s ./libclntsh.so.11.1 ./libclntsh.so
ln -s ./libclntsh.so.11.1 ./libclntsh.so.10.1
大功告成!文章来源地址https://www.toymoban.com/news/detail-621088.html
到了这里,关于报错:/usr/bin/ld: 找不到 -lclntsh: 没有那个文件或目录的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!