aldebaran / libqi

NAOqi core framework
http://doc.aldebaran.com/libqi/
BSD 3-Clause "New" or "Revised" License
66 stars 53 forks source link

Error while loading shared libraries: libopencv_imgproc.so #25

Closed alex-kozinov closed 4 years ago

alex-kozinov commented 5 years ago

I've wrote my own module, using openCV and qitoolchain to linux-sdk. And after running executable file I always receive such error:

./build-linux-sdk/sdk/bin/remotevision: error while loading shared libraries: libopencv_imgproc.so.3.1: cannot open shared object file: No such file or directory
Makefile:25: recipe for target 'run' failed
make: *** [run] Error 127

Please help me. I've been searching for solutions several days

nyibbang commented 5 years ago

Hello @alex-kozinov,

It seems like your problem is more related to qibuild than libqi, but maybe we can help you as it seems you have an issue of library search paths.

What system are you using ? Which version of qibuild ?

Could you try to run ldd ./build-linux-sdk/sdk/bin/remotevision and see if it outputs the path to the missing library or not, and also readelf -d ./build-linux-sdk/sdk/bin/remotevision and check that the RPATH (or RUNPATH) variable contains the path to the library directory.

alex-kozinov commented 5 years ago

Thank for your attention to this problem! I am using:

Also I've ran command ldd ./build-linux-sdk/sdk/bin/remotevision and revealed that this library was mentioned:

    /lib64/ld-linux-x86-64.so.2 (0x00007f8edf41c000)
    libopencv_imgproc.so.3.1 => not found
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f8ed98a3000)
    libopencv_imgproc.so.3.1 => not found

Then i've looked up to RPATH:


 0x0000000000000001 (NEEDED)             Shared library: [libalproxies.so]
 0x0000000000000001 (NEEDED)             Shared library: [libalcommon.so]
 0x0000000000000001 (NEEDED)             Shared library: [libalvalue.so]
 0x0000000000000001 (NEEDED)             Shared library: [libalerror.so]
 0x0000000000000001 (NEEDED)             Shared library: [libqi.so]
 0x0000000000000001 (NEEDED)             Shared library: [libboost_system.so.1.59.0]
 0x0000000000000001 (NEEDED)             Shared library: [libpthread.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libopencv_highgui.so.3.1]
 0x0000000000000001 (NEEDED)             Shared library: [libopencv_imgcodecs.so.3.1]
 0x0000000000000001 (NEEDED)             Shared library: [libopencv_objdetect.so.3.1]
 0x0000000000000001 (NEEDED)             Shared library: [libopencv_core.so.3.1]
 0x0000000000000001 (NEEDED)             Shared library: [libstdc++.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 0x000000000000001d (RUNPATH)            Library runpath: [/home/aleksey/sdks/linux-sdk/lib:]
``
Its quite strange for me that there isn't libopencv_imgproc in this list. 
But i don't know exactly how it works(: 
nyibbang commented 5 years ago

Are you building libqi yourself ? Are you using a Makefile generator when configuring your project with qibuild ? If so can you do a grep -R "\-Wl,\-rpath" in your build directory ?

We have had issues with the RUNPATH option from Ubuntu 18.04 as the behavior changed from the RPATH of Ubuntu 16.04. Technically we only support 16.04 at the moment, but as a workaround you can try using export LD_LIBRARY_PATH=$HOME/.local/share/qi/toolchains/linux-sdk/opencv3/lib before running your program (if you have a similar error but with another library, try adding the path to the lib to the LD_LIBRARY_PATH). Note that we do not advise using a LD_LIBRARY_PATH as a long-term solution, see it as a workaround for now.

alex-kozinov commented 5 years ago

Ohh i've been so afraid when reinsall ubuntu. Thanks you that help to find solution. In Makefile I just run qibuild configure and qibuild make

cdbuild-linux-sdk/CMakeFiles/remotevision.dir/link.txt:/usr/bin/c++  -std=gnu++11 -D_GLIBCXX_USE_CXX11_ABI=0 -g  -rdynamic CMakeFiles/remotevision.dir/balldetector.cpp.o CMakeFiles/remotevision.dir/markdetector.cpp.o CMakeFiles/remotevision.dir/kernelcv.cpp.o CMakeFiles/remotevision.dir/remotevision.cpp.o CMakeFiles/remotevision.dir/main.cpp.o  -o sdk/bin/remotevision -Wl,-rpath,/home/aleksey/sdks/linux-sdk/lib: /home/aleksey/sdks/linux-sdk/lib/libalvision.so /home/aleksey/sdks/linux-sdk/lib/libalextractor.so /home/aleksey/sdks/linux-sdk/lib/libalthread.so /home/aleksey/sdks/linux-sdk/lib/libalproxies.so /home/aleksey/sdks/linux-sdk/lib/libalcommon.so /home/aleksey/sdks/linux-sdk/lib/libboost_signals.so /home/aleksey/sdks/linux-sdk/lib/librttools.so /home/aleksey/sdks/linux-sdk/lib/libalvalue.so /home/aleksey/sdks/linux-sdk/lib/libalerror.so /home/aleksey/sdks/linux-sdk/lib/libqi.so /home/aleksey/sdks/linux-sdk/lib/libboost_date_time.so /home/aleksey/sdks/linux-sdk/lib/libboost_chrono.so /home/aleksey/sdks/linux-sdk/lib/libboost_filesystem.so /home/aleksey/sdks/linux-sdk/lib/libboost_system.so /home/aleksey/sdks/linux-sdk/lib/libboost_regex.so /home/aleksey/sdks/linux-sdk/lib/libboost_program_options.so /home/aleksey/sdks/linux-sdk/lib/libssl.so /home/aleksey/sdks/linux-sdk/lib/libcrypto.so /home/aleksey/sdks/linux-sdk/lib/libboost_locale.so /home/aleksey/sdks/linux-sdk/lib/libboost_thread.so /home/aleksey/sdks/linux-sdk/lib/libicudata.so /home/aleksey/sdks/linux-sdk/lib/libicudata.so.52 /home/aleksey/sdks/linux-sdk/lib/libicui18n.so /home/aleksey/sdks/linux-sdk/lib/libicui18n.so.52 /home/aleksey/sdks/linux-sdk/lib/libicuio.so /home/aleksey/sdks/linux-sdk/lib/libicuio.so.52 /home/aleksey/sdks/linux-sdk/lib/libicule.so /home/aleksey/sdks/linux-sdk/lib/libicule.so.52 /home/aleksey/sdks/linux-sdk/lib/libiculx.so /home/aleksey/sdks/linux-sdk/lib/libiculx.so.52 /home/aleksey/sdks/linux-sdk/lib/libicutest.so /home/aleksey/sdks/linux-sdk/lib/libicutest.so.52 /home/aleksey/sdks/linux-sdk/lib/libicutu.so /home/aleksey/sdks/linux-sdk/lib/libicutu.so.52 /home/aleksey/sdks/linux-sdk/lib/libicuuc.so /home/aleksey/sdks/linux-sdk/lib/libicuuc.so.52 -lpthread -ldl -lrt /home/aleksey/sdks/linux-sdk/lib/libopencv_highgui.so /home/aleksey/sdks/linux-sdk/lib/libopencv_imgcodecs.so /home/aleksey/sdks/linux-sdk/lib/libopencv_imgproc.so /home/aleksey/sdks/linux-sdk/lib/libopencv_objdetect.so /home/aleksey/sdks/linux-sdk/lib/libopencv_features2d.so /home/aleksey/sdks/linux-sdk/lib/libopencv_flann.so /home/aleksey/sdks/linux-sdk/lib/libopencv_core.so /home/aleksey/sdks/linux-sdk/lib/libz.so 
nyibbang commented 5 years ago

Ah yes my bad, it seems your packages are in $HOME/sdks/linux-sdk, and it seems like opencv is missing in the rpath arguments of the linker. You can try export LD_LIBRARY_PATH=$HOME/sdks/linux-sdk/lib before running your program then.