c++ - OpenCV 与 OpenWRT 交叉编译时出错

标签 c++ linux opencv cross-compiling openwrt

我在 OpenCv 交叉编译过程中遇到了问题 (使用OpenWrt,发布Attitude Adjustment (12.09-rc1),平台ar71xx)。 似乎 OpenWRt 链接器找不到合适的库...

[ 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`

我堆在这里,无法继续前进,所以我正在寻求帮助。 我不会用 OpenWRT 编译 OpenCv,但是当我尝试使用来自 here 的库时和 here

我收到以下错误:

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'

有没有人可以帮助我?

已编辑:

添加 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

最佳答案

这是链接问题 - 您必须指定所有库,您已经使用了其中的函数。在这种情况下 - 还可以使用 -lzlib - lpthread 选项进行链接。

对于所有类似的问题 - 谷歌功能你得到一个错误并找到它属于哪个库。然后链接到它。

关于c++ - OpenCV 与 OpenWRT 交叉编译时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22450508/

相关文章:

c++ - fstream中怎么写?

linux - Lazarus Indy SSL IdHTTP

linux - 关闭后如何制作 LESS 'remember' 搜索模式?

linux - pthread_rwlock_init() 导致段错误

visual-studio - LNK1112 : module machine type 'x64' conflicts with target machine type 'x86' - opencv build

c++如何用数组中的字符串替换另一个字符串

c++ - 用于读取 double 的 istream 操纵器

c++ - 将一个 va_list 作为参数传递给另一个

c - 开发 C++ 与 OpenCV 崩溃

c++ - 在 opencv 2.3 中从 RGB 图像中分离出红色分量图像