1. Specific error report
error while loading shared libraries: libopencv_core.so.4.5: cannot open shared object file: No such file or directory
2. Root cause of the problem
The compiler cannot find the path to the installed opencv library
3. Solution
-
Find the path to the specified library
sudo find / -name "libopencv_core.so.4.5"
Query results (terminal output):
/usr/local/opencv4.5.1/lib/libopencv_core.so.4.5
-
Tell the system the path to the specified library
sudo gedit /etc/ld.so.conf.d/opencv.conf # 在文件末尾加上查询结果 /usr/local/opencv4.5.1/lib/libopencv_core.so.4.5 # 然后运行 sudo ldconfig -v