環境:
Ubuntu 11.10 + TQ的交叉編譯鏈4.46 + cmake-2.8.12.2-Linux-i386 + OpenCV-2.4.1
配置的我就說了,網上有很多,自己去找。主要說一些錯誤的解決的辦法。
例如:我在 /usr/local/Opencv-2.4.1放Opencv源碼,另外在 /usr/local下新建Opencv-arm目錄存放交叉編譯後的庫配置好後,執行cmake-gui,在彈出的窗口中的"Where is the source code"選擇Opencv源碼目錄Opencv-2.4.1;在"Where to build the binarices"選擇存放交叉編譯的目錄Opencv-arm,點擊左下角的configure,彈出一個窗口,框條選擇“Unix Makefiles”,下面的選擇最後一個;然後點擊finish;然後彈出新窗口,“Operating System”填寫arm-linux,“Version”填寫Opencv版本(2.4.1);“C”選擇交叉編譯鏈(/opt/EmbedSky/4.4.6/bin/arm-linux-gcc);“C++”選擇交叉編譯鏈(/opt/EmbedSky/4.4.6/bin/arm-linux-g++);“Target Root”選擇交叉編譯鏈的目錄(/opt/EmbedSky/4.4.6/);然後點擊Finished;(重點來了)彈出的紅框中去掉BUILD_OPENER、BUILD_TIFF、BUILD_ZLIB、WITH_OPENER、WITH_TIFF其他的默認就行,點擊Generate,OK!若重新cmake-gui最好在彈出的框中選擇File-->Delete Cache,然後重新配置。基本可以省去幾個錯誤!!!
配置完,進入交叉編譯庫存放的目錄(Opencv-arm)進行make,然後報錯了(不一定都有)~~~
--------------------------------------分割線 --------------------------------------
推薦閱讀:
Ubuntu Linux下安裝OpenCV2.4.1所需包 http://www.linuxidc.com/Linux/2012-08/68184.htm
Ubuntu 12.04 安裝 OpenCV2.4.2 http://www.linuxidc.com/Linux/2012-09/70158.htm
CentOS下OpenCV無法讀取視頻文件 http://www.linuxidc.com/Linux/2011-07/39295.htm
Ubuntu 12.04下安裝OpenCV 2.4.5總結 http://www.linuxidc.com/Linux/2013-06/86704.htm
Ubuntu 10.04中安裝OpenCv2.1九步曲 http://www.linuxidc.com/Linux/2010-09/28678.htm
基於QT和OpenCV的人臉識別系統 http://www.linuxidc.com/Linux/2011-11/47806.htm
--------------------------------------分割線 --------------------------------------
錯誤分析:
1,XML::Parser perl module is required for intltool錯誤
解決:cpan install XML::Parser
2,
版本問題(64位Ubuntu)
解決:
進入opencv目錄下的3rdparty的對應目錄CMakeFiles/ *.dir下(所有的),打開flags.make,在C_FLAGS = 後添加-O3 -fPIC,用來支持在64位機上編譯
如../3rdparty/zlib/CMakeFiles/zlib.dir/flags.make
修改C_FLAGS = -W -Wall 為 C_FLAGS = -O3 -fPIC -W -Wall
和
修改CXX_FLAGS = -W -Wall 為 C_FLAGS = -O3 -fPIC -W -Wall
3,
解決:
在cmake-gui的界面中把以下選項去掉
BUILD_OPENER、BUILD_TIFF
4,
Linking CXX executable ../../bin/opencv_test_calib3d
../../lib/libopencv_core.so: undefined reference to `pthread_key_create'
../../lib/libopencv_core.so: undefined reference to `pthread_getspecific'
../../lib/libopencv_ts.so: undefined reference to `pthread_key_delete'
../../lib/libopencv_core.so: undefined reference to `pthread_once'
../../lib/libopencv_core.so: undefined reference to `clock_gettime'
../../lib/libopencv_core.so: undefined reference to `pthread_setspecific'
collect2: ld returned 1 exit status
make[2]: *** [bin/opencv_test_calib3d] Error 1
make[1]: *** [modules/calib3d/CMakeFiles/opencv_test_calib3d.dir/all] Error 2
make: *** [all] Error 2
解決( ld returned 1 exit status都可以):
修改目錄下的CMakeCache.txt,CMAKE_EXE_LINKER_FLAGS原來為空,加上-lpthread -lrt