error while loading shared libraries错误的原因及解決方法

使用openCV库的时候出现的问题,记录一下:
报错内容:

error while loading shared libraries: libopencv_world.so.4.5: cannot open shared object file: No such file or directory

首先检查库的文件是不是真的存在,如果真的存在,那么则是因为系统链接库时路径不对,系统没有按照你预想的路径去检索。这时我们只需要人为去指定路径即可:
首先打开这个文件:

sudo gedit /etc/ld.so.conf

文件中默认有如下的内容:

include /etc/ld.so.conf.d/*.conf

这时在文件中添加目标动态库目录:

include /etc/ld.so.conf.d/*.conf \
/home/zys/lib/opencv454_install/lib

注意:一定要加续行符!!否则不行~
更新文件:

sudo ldconfig

这样就可以了~

你可能感兴趣的:(linux,linux)