I am Trying to cross compiling OpenCV application statically by using following command
$ cmake -DCMAKE_TOOLCHAIN_FILE=../riscv.toolchain.cmake ../../.. -DWITH_PNG=OF -DBUILD_SHARED_LIBS=OFF -DCMAKE_EXE_LINKER_FLAGS="-static" .
I am getting error as below
../../lib/libopencv_core.a(opencl_core.cpp.o): In function GetHandle(char const*)':
opencl_core.cpp:(.text._ZL9GetHandlePKc+0xc): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: attempted static link of dynamic object
/usr/local/lib/libz.so'
collect2: error: ld returned 1 exit status
apps/version/CMakeFiles/opencv_version.dir/build.make:96: recipe for target 'bin/opencv_version' failed
make[2]: * [bin/opencv_version] Error 1
Please help me regarding this error.
Thanks in advance
have you tried
-DBUILD_ZLIB=ON
? (so it will build it's own, static zlib, instead of relying on your system's libz.so)also, you probably meant:
-DWITH_PNG=OFF
(typo?)then, please do not run cmake from the src folder, but make a "build" folder, and cd into that. (else it is next to impossible to clean up !)
cmake -DCMAKE_TOOLCHAIN_FILE=../riscv.toolchain.cmake ../../..cmake -DCMAKE_TOOLCHAIN_FILE=../riscv.toolchain.cmake ../../.. -DWITH_PNG=OFF -DBUILD_SHARED_LIBS=OFF -DBUILD_ZLIB=ON -DWITH_PNG=OFF -DCMAKE_EXE_LINKER_FLAGS="-static"
Even after adding -DBUILD_ZLIB=ON also i am getting same error:
../../lib/libopencv_core.a(opencl_core.cpp.o): In function
GetHandle(char const*)': opencl_core.cpp:(.text._ZL9GetHandlePKc+0xc): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/bin/ld: attempted static link of dynamic object
/usr/lib/x86_64-linux-gnu/libjpeg.so' collect2: error: ld returned 1 exit status apps/visualisation/CMakeFiles/opencv_visualisation.dir/build.make:110: recipe for target 'bin/opeplease put msgs like that into your question, where it can be properly formatted.
and you want to use -DBUILD_JPEG=ON -DBUILD_TIFF=ON, etc. for ALL your image codecs required or disable them entirely like -DWITH_JPEG=OFF
idk, what to do about the opencl warning. you probably do not have a static opencl lib.
Now I am getting some other error of the same fashion.
../../lib/libopencv_core.a(opencl_core.cpp.o): In function
GetHandle(char const*)': opencl_core.cpp:(.text._ZL9GetHandlePKc+0xc): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/bin/ld: attempted static link of dynamic object
/usr/lib/x86_64-linux-gnu/libtiff.so' collect2: error: ld returned 1 exit status apps/annotation/CMakeFiles/opencv_annotation.dir/build.make:108: recipe for target 'bin/opencv_annotation' failed make[2]: * [bin/opencv_annotation] Error 1 CMakeFiles/Makefile2:4238: recipe for target 'apps/annotation/CMakeFiles/opencv_annotation.dir/all' failed make[1]: * [apps/annotation/CMakeFiles/opencv_annotation.dir/all] Errorand the answer is still the same -- either build the 3rd party version or disable it.
I am successfully cross compiled opencv for riscv architecture statically.now i am trying to run opencv application but i am getting error.please help me. error :- /usr/bin/ld: skipping incompatible /home/billa/Documents/opencv/platforms/linux/build_riscv/install/lib/libopencv_ml.a when searching for -lopencv_ml /usr/bin/ld: skipping incompatible /home/billa/Documents/opencv/platforms/linux/build_riscv/install/lib/libopencv_videostab.a when searching for -lopencv_videostab /usr/bin/ld: skipping incompatible /home/billa/Documents/opencv/platforms/linux/build_riscv/install/lib/libopencv_stitching.a when searching for -lopencv_stitching /usr/bin/ld: skipping incompatible /home/billa/Documents/opencv/platforms/linux/build_riscv/install/lib/libopencv_calib3d.a when searching for -lopencv_cali