與X86 Linux類似,請參考: Linux 下編譯安裝OpenCV 本文在此基礎上進行進一步操作。
網絡上很多移植編譯的方法比較老,多數針對OpenCV 1.0,而且方法很麻煩,不仔細操作很容易出錯,我的方法是盡可能的利用現成的工具,盡量圖形化界面配置操作,方便編譯配置。
Qt 的詳細介紹:請點這裡
Qt 的下載地址:請點這裡
Linking CXX executable ../../bin/opencv_perf_core ../../lib/libopencv_highgui.so: undefined reference to `_TIFFmemcpy' ../../lib/libopencv_core.so: undefined reference to `pthread_spin_init' ../../lib/libopencv_core.so: undefined reference to `pthread_spin_unlock' ../../lib/libopencv_highgui.so: undefined reference to `_TIFFmemset' ../../lib/libopencv_highgui.so: undefined reference to `_TIFFwarningHandler' ../../lib/libopencv_core.so: undefined reference to `pthread_key_create' ../../lib/libopencv_highgui.so: undefined reference to `_TIFFmemcmp' ../../lib/libopencv_core.so: undefined reference to `pthread_getspecific' ../../lib/libopencv_highgui.so: undefined reference to `_TIFFfree' ../../lib/libopencv_ts.so: undefined reference to `pthread_key_delete' ../../lib/libopencv_core.so: undefined reference to `pthread_spin_lock' ../../lib/libopencv_highgui.so: undefined reference to `_TIFFmalloc' ../../lib/libopencv_highgui.so: undefined reference to `TIFFOpen' ../../lib/libopencv_core.so: undefined reference to `pthread_spin_destroy' ../../lib/libopencv_core.so: undefined reference to `pthread_once' ../../lib/libopencv_highgui.so: undefined reference to `_TIFFrealloc' ../../lib/libopencv_core.so: undefined reference to `clock_gettime' ../../lib/libopencv_core.so: undefined reference to `pthread_spin_trylock' ../../lib/libopencv_highgui.so: undefined reference to `_TIFFerrorHandler' ../../lib/libopencv_core.so: undefined reference to `pthread_setspecific' collect2: ld returned 1 exit status make[2]: *** [bin/opencv_perf_core] 錯誤 1 make[1]: *** [modules/core/CMakeFiles/opencv_perf_core.dir/all] 錯誤 2 make: *** [all] 錯誤 2
關於TIFF的報錯,是因為一開始我勾選了TIFF的支持,而這個支持是需要宿主機中安裝相應的程序的,所以報錯,可以打開cmake 去掉勾選。 其他報錯經過查找找到以下解釋:
編譯時發現如下錯誤:
Linking CXX executable ../../bin/opencv_createsamples
../../lib/libcxcore.so: undefined reference to `clock_gettime'
../../lib/libcxcore.so: undefined reference to `pthread_key_create'
../../lib/libcxcore.so: undefined reference to `pthread_getspecific'
../../lib/libcxcore.so: undefined reference to `pthread_setspecific'原因是cmake不認識我定義的arm-linux系統標記,沒有加上庫pthread和rt的鏈接選項
此時需要修改CMakeCache.txt,CMAKE_EXE_LINKER_FLAGS原來為空,加上-lpthread -lrt
按照此方法更改對應文件,如下圖所示:
此處在CMakeCache.txt 的173行,添加-lpthread -lrt,然後繼續編譯。編譯過程十來分鐘左右,編譯成功結果如下:
運行make install進行安裝,在我的安裝目錄中就會多出以下幾個文件夾:
lib文件夾即生成的庫文件,拷貝到開發板對應目錄即可。