Ask Your Question

Revision history [back]

warning: ../../lib/libopencv_core.so, needed by ./lib/libopencv_highgui.so, not found (try using -rpath or -rpath-link)

I have built the opencv project with cmake without errors. But when I compiled my project, I got warnings like this:

warning: ../../lib/libopencv_core.so, needed by ./lib/libopencv_highgui.so, not found (try using -rpath or -rpath-link) I copyed the opencv library to the current folder and configed the environment. Then I run it and got the following error:

error while loading shared libraries: ../../lib/libopencv_videoio.so I found it is because the compiler options in these files called link.txt. They are in their own folder like build/modules//CMakeFiles/opencv_.dir. For example, the link.txt of highgui is in build/modules/highgui/CMakeFiles/opencv_highgui.dir/. And the build folder is built by cmake-gui. These files is writed like this:

g++ -fPIC -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -Wno-deprecated-declarations -O3 -DNDEBUG -DNDEBUG -lpthread -ldl -lm -lrt -Wl,-rpath-link=./lib -Wl,-rpath=./lib -shared -o ../../lib/libopencv_highgui.so CMakeFiles/opencv_highgui.dir/src/window.cpp.obj CMakeFiles/opencv_highgui.dir/src/roiSelector.cpp.obj ../../lib/libopencv_videoio.so ../../lib/libopencv_imgcodecs.so ../../lib/libopencv_imgproc.so ../../lib/libopencv_core.so

Because the file libopencv_core.so is depended by libopencv_highgui.so, I have to copy these *.so to the ../../lib folder relative to current folder. Then it runs.

How to solve the problem when building opencv?

warning: ../../lib/libopencv_core.so, needed by ./lib/libopencv_highgui.so, not found (try using -rpath or -rpath-link)

I have built the opencv project with cmake without errors. But when I compiled my project, I got warnings like this:

warning: ../../lib/libopencv_core.so, needed by ./lib/libopencv_highgui.so, not found (try using -rpath or -rpath-link) -rpath-link)

I copyed the opencv library to the current folder and configed the environment. Then I run it and got the following error:

error while loading shared libraries: ../../lib/libopencv_videoio.so ../../lib/libopencv_videoio.so

I found it is because the compiler options in these files called link.txt. They are in their own folder like build/modules//CMakeFiles/opencv_.dir. For example, the link.txt of highgui is in build/modules/highgui/CMakeFiles/opencv_highgui.dir/. And the build folder is built by cmake-gui. These files is writed like this:

g++ -fPIC -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -Wno-deprecated-declarations -O3 -DNDEBUG -DNDEBUG -lpthread -ldl -lm -lrt -Wl,-rpath-link=./lib -Wl,-rpath=./lib -shared -o ../../lib/libopencv_highgui.so CMakeFiles/opencv_highgui.dir/src/window.cpp.obj CMakeFiles/opencv_highgui.dir/src/roiSelector.cpp.obj ../../lib/libopencv_videoio.so ../../lib/libopencv_imgcodecs.so ../../lib/libopencv_imgproc.so ../../lib/libopencv_core.so

Because the file libopencv_core.so is depended by libopencv_highgui.so, I have to copy these *.so to the ../../lib folder relative to current folder. Then it runs.

How to solve the problem when building opencv?