Question

I have faced problem during OpenCv cross-comipilation (with OpenWrt, release Attitude Adjustment (12.09-rc1), platform ar71xx). It seems that OpenWRt linker could not find proper libraries...

[ 27%] Built target opencv_ts
Linking CXX executable ../../bin/opencv_perf_core
mips-openwrt-linux-uclibc-g++.bin: warning: environment variable 'STAGING_DIR' not defined
mips-openwrt-linux-uclibc-g++.bin: warning: environment variable 'STAGING_DIR' not defined
/home/pawel/openwrt/OpenWrt-Toolchain-ar71xx-for-mips_r2-gcc-4.6-linaro_uClibc-0.9.33.2/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/bin/../lib/gcc/mips-openwrt-linux-uclibc/4.6.3/../../../../mips-openwrt-linux-uclibc/bin/ld: skipping incompatible /usr/lib/gcc/i686-linux-gnu/4.8/libstdc++.so when searching for -lstdc++

/home/pawel/openwrt/OpenWrt-Toolchain-ar71xx-for-mips_r2-gcc-4.6-linaro_uClibc-0.9.33.2/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/bin/../lib/gcc/mips-openwrt-linux-uclibc/4.6.3/../../../../mips-openwrt-linux-uclibc/bin/ld: skipping incompatible /usr/lib/gcc/i686-linux-gnu/4.8/libstdc++.a when searching for -lstdc++

/home/pawel/openwrt/OpenWrt-Toolchain-ar71xx-for-mips_r2-gcc-4.6-linaro_uClibc-0.9.33.2/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/bin/../lib/gcc/mips-openwrt-linux-uclibc/4.6.3/../../../../mips-openwrt-linux-uclibc/bin/ld: cannot find -lv4l1

/home/pawel/openwrt/OpenWrt-Toolchain-ar71xx-for-mips_r2-gcc-4.6-linaro_uClibc-0.9.33.2/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/bin/../lib/gcc/mips-openwrt-linux-uclibc/4.6.3/../../../../mips-openwrt-linux-uclibc/bin/ld: cannot find -lavcodec

/home/pawel/openwrt/OpenWrt-Toolchain-ar71xx-for-mips_r2-gcc-4.6-linaro_uClibc-0.9.33.2/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/bin/../lib/gcc/mips-openwrt-linux-uclibc/4.6.3/../../../../mips-openwrt-linux-uclibc/bin/ld: cannot find -lavformat
/home/pawel/openwrt/OpenWrt-Toolchain-ar71xx-for-mips_r2-gcc-4.6-linaro_uClibc-0.9.33.2/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/bin/../lib/gcc/mips-openwrt-linux-uclibc/4.6.3/../../../../mips-openwrt-linux-uclibc/bin/ld: cannot find -lavutil

/home/pawel/openwrt/OpenWrt-Toolchain-ar71xx-for-mips_r2-gcc-4.6-linaro_uClibc-0.9.33.2/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/bin/../lib/gcc/mips-openwrt-linux-uclibc/4.6.3/../../../../mips-openwrt-linux-uclibc/bin/ld: cannot find -lswscale

/home/pawel/openwrt/OpenWrt-Toolchain-ar71xx-for-mips_r2-gcc-4.6-linaro_uClibc-0.9.33.2/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/bin/../lib/gcc/mips-openwrt-linux-uclibc/4.6.3/../../../../mips-openwrt-linux-uclibc/bin/ld: cannot find -lbz2

/home/pawel/openwrt/OpenWrt-Toolchain-ar71xx-for-mips_r2-gcc-4.6-linaro_uClibc-0.9.33.2/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/bin/../lib/gcc/mips-openwrt-linux-uclibc/4.6.3/../../../../mips-openwrt-linux-uclibc/bin/ld: cannot find -lz

/home/pawel/openwrt/OpenWrt-Toolchain-ar71xx-for-mips_r2-gcc-4.6-linaro_uClibc-0.9.33.2/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/bin/../lib/gcc/mips-openwrt-linux-uclibc/4.6.3/../../../../mips-openwrt-linux-uclibc/bin/ld: skipping incompatible /usr/lib/gcc/i686-linux-gnu/4.8/libstdc++.so when searching for -lstdc++

/home/pawel/openwrt/OpenWrt-Toolchain-ar71xx-for-mips_r2-gcc-4.6-linaro_uClibc-0.9.33.2/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/bin/../lib/gcc/mips-openwrt-linux-uclibc/4.6.3/../../../../mips-openwrt-linux-uclibc/bin/ld: skipping incompatible /usr/lib/gcc/i686-linux-gnu/4.8/libstdc++.a when searching for -lstdc++

collect2: ld returned 1 exit status
make[2]: *** [bin/opencv_perf_core] Błąd 1
make[1]: *** [modules/core/CMakeFiles/opencv_perf_core.dir/all] Błąd 2
make: *** [all] Błąd 2`

I stacked here and I am not able to move on so I am looking for some help. I would not compile OpenCv with OpenWRT but when I was trying to use libs from here and here

I got following error :

Building target: misp
Invoking: Cross G++ Linker
mips-openwrt-linux-g++ -L/home/prog12/openwrtD/openwrt/opencv_libs/ar71xx-WR703N/debug/ -o "misp"  ./src/main.o   -lopencv_highgui -lopencv_core -lopencv_imgproc -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann
mips-openwrt-linux-uclibc-g++.bin: warning: environment variable 'STAGING_DIR' not defined
mips-openwrt-linux-uclibc-g++.bin: warning: environment variable 'STAGING_DIR' not defined

/home/prog12/openwrtD/openwrt/opencv_libs/ar71xx-WR703N/debug//libopencv_core.a(system.cpp.o): In function `cv::Mutex::Mutex()':
system.cpp:(.text._ZN2cv5MutexC2Ev+0x38): undefined reference to `pthread_spin_init'
system.cpp:(.text._ZN2cv5MutexC2Ev+0x40): undefined reference to `pthread_spin_init'

/home/prog12/openwrtD/openwrt/opencv_libs/ar71xx-WR703N/debug//libopencv_core.a(system.cpp.o): In function `cv::Mutex::~Mutex()':
system.cpp:(.text._ZN2cv5MutexD2Ev+0x78): undefined reference to `pthread_spin_destroy'
system.cpp:(.text._ZN2cv5MutexD2Ev+0x80): undefined reference to `pthread_spin_destroy'

/home/prog12/openwrtD/openwrt/opencv_libs/ar71xx-WR703N/debug//libopencv_core.a(system.cpp.o): In function `cv::Mutex::operator=(cv::Mutex const&)':
system.cpp:(.text._ZN2cv5MutexaSERKS0_+0xa4): undefined reference to `pthread_spin_destroy'
system.cpp:(.text._ZN2cv5MutexaSERKS0_+0xac): undefined reference to `pthread_spin_destroy'

Is there someone who could help me?

EDITED:

Also faced problem adding zlib( thx to old-ufo).

Building target: misp
Invoking: Cross G++ Linker
mips-openwrt-linux-g++ -L/home/prog12/openwrtD/openwrt/opencv_libs/ar71xx-WR703N/debug/ -o "misp"  ./src/main.o   -lpthread -lzlib -lopencv_highgui -lopencv_core -lopencv_imgproc -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann
mips-openwrt-linux-uclibc-g++.bin: warning: environment variable 'STAGING_DIR' not defined
mips-openwrt-linux-uclibc-g++.bin: warning: environment variable 'STAGING_DIR' not defined
/home/prog12/openwrt/OpenWrt-Toolchain-ar71xx-for-mips_r2-gcc-4.6-linaro_uClibc-0.9.33.2/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/bin/../lib/gcc/mips-openwrt-linux-uclibc/4.6.3/../../../../mips-openwrt-linux-uclibc/bin/ld: cannot find -lzlib
Was it helpful?

Solution

It is linking problem - you have to specify all libraries, you have used functions from. In this case - link also with -lzlib - lpthread options.

For the all similar problems - google function on which you get an error and find to which library it belongs. Then link to it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top