cmake -DCMAKE_SYSTEM_NAME=arm-linux -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local/opencv-arm -D CMAKE_C_COMPILER=arm-linux-gcc -D CMAKE_CXX_COMPILER=arm-linux-g++ -D CMAKE_EXE_LINKER_FLAGS="-lpthread -lrt" -D WITH_TIFF=OFF ..
b,把opencv for arm的库/usr/local/opencv-arm/lib拷贝到开发板,一般拷贝到开发板的/lib目录或者/usr/lib目录。
c,编译应用程序测试:说明这里仅仅是一种编译的方法,drawing.cpp包含GUI部分,编译后放在开发板上跑不起来,所以对于GUI部分考虑先移植QT,用QT来显示。
arm-linux-g++ -I/usr/local/opencv-arm/include -L/usr/local/opencv-arm/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann -lpthread -lrt drawing.cpp -o drawing
等同:下面这个使用PKG-CONFIG来管理opencv的头文件和库文件。
=============================================================
arm-linux-g++ `pkg-config --cflags --libs opencv-arm` drawing.cpp
=================================================================
d,若在开发板上运行程序,提示缺少xxopencv库,而该库已经拷贝到开发板,此种情况需要更改库的软连接,或者重命名库的名字。
ldd drawing//see the dynmic link object, drawing is a example of excutable
file drawing//see drawing's platform that is gcc build or arm-linux-gcc build.
Variable Name: OPENCV_CONFIG_FILE_INCLUDE_DIR
Description: Where to create the platform-dependant cvconfig.h
Current Value: /root/opencv_arm/OpenCV-2.3.0
Variable Name: CMAKE_CXX_COMPILER
Description: CXX compiler.
Current Value: /usr/lib/ccache/c++
Variable Name: CMAKE_C_COMPILER
Description: C compiler.
Current Value: /usr/lib/ccache/gcc
g++ -I/usr/local/opencv-pc/include -L/usr/local/opencv-pc/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann drawing.cpp
===============================================================
g++ `pkg-config --cflags --libs opencv` drawing.cpp
===============================================================
linux-gate.so.1 => (0x00ce2000)
libopencv_core.so.2.3 => /usr/local/opencv-pc/lib/libopencv_core.so.2.3 (0x004c0000)
libopencv_imgproc.so.2.3 => /usr/local/opencv-pc/lib/libopencv_imgproc.so.2.3 (0x00110000)
libopencv_highgui.so.2.3 => /usr/local/opencv-pc/lib/libopencv_highgui.so.2.3 (0x006f4000)
libopencv_ml.so.2.3 => /usr/local/opencv-pc/lib/libopencv_ml.so.2.3 (0x0036c000)
libopencv_video.so.2.3 => /usr/local/opencv-pc/lib/libopencv_video.so.2.3 (0x003e2000)
libopencv_features2d.so.2.3 => /usr/local/opencv-pc/lib/libopencv_features2d.so.2.3 (0x00776000)
libopencv_calib3d.so.2.3 => /usr/local/opencv-pc/lib/libopencv_calib3d.so.2.3 (0x0086d000)
libopencv_objdetect.so.2.3 => /usr/local/opencv-pc/lib/libopencv_objdetect.so.2.3 (0x00e26000)
libopencv_contrib.so.2.3 => /usr/local/opencv-pc/lib/libopencv_contrib.so.2.3 (0x00f04000)
libopencv_legacy.so.2.3 => /usr/local/opencv-pc/lib/libopencv_legacy.so.2.3 (0x00922000)
libopencv_flann.so.2.3 => /usr/local/opencv-pc/lib/libopencv_flann.so.2.3 (0x0041f000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x07ed2000)
libm.so.6 => /lib/libm.so.6 (0x00d61000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00d8d000)
libc.so.6 => /lib/libc.so.6 (0x00f44000)
libpthread.so.0 => /lib/libpthread.so.0 (0x00d19000)
libdl.so.2 => /lib/libdl.so.2 (0x00d37000)
librt.so.1 => /lib/librt.so.1 (0x00d55000)
libz.so.1 => /lib/libz.so.1 (0x00d3e000)
libjpeg.so.62 => /usr/lib/libjpeg.so.62 (0x02858000)
libpng12.so.0 => /usr/lib/libpng12.so.0 (0x00426000)
libtiff.so.3 => /usr/lib/libtiff.so.3 (0x0044e000)
libgtk-x11-2.0.so.0 => /usr/lib/libgtk-x11-2.0.so.0 (0x07a2d000)
libgdk-x11-2.0.so.0 => /usr/lib/libgdk-x11-2.0.so.0 (0x009d0000)
libatk-1.0.so.0 => /usr/lib/libatk-1.0.so.0 (0x006b0000)
libgio-2.0.so.0 => /lib/libgio-2.0.so.0 (0x00b82000)
libpangoft2-1.0.so.0 => /usr/lib/libpangoft2-1.0.so.0 (0x00a8a000)
libpangocairo-1.0.so.0 => /usr/lib/libpangocairo-1.0.so.0 (0x004af000)
libgdk_pixbuf-2.0.so.0 => /usr/lib/libgdk_pixbuf-2.0.so.0 (0x006cf000)
libcairo.so.2 => /usr/lib/libcairo.so.2 (0x097f4000)
libpango-1.0.so.0 => /usr/lib/libpango-1.0.so.0 (0x00ab7000)
libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0x09150000)
libfontconfig.so.1 => /usr/lib/libfontconfig.so.1 (0x00b00000)
libgobject-2.0.so.0 => /lib/libgobject-2.0.so.0 (0x00daa000)
libgmodule-2.0.so.0 => /lib/libgmodule-2.0.so.0 (0x004bb000)
libgthread-2.0.so.0 => /lib/libgthread-2.0.so.0 (0x00b35000)
libglib-2.0.so.0 => /lib/libglib-2.0.so.0 (0x08789000)
/lib/ld-linux.so.2 (0x00b60000)
libX11.so.6 => /usr/lib/libX11.so.6 (0x010d7000)
libXfixes.so.3 => /usr/lib/libXfixes.so.3 (0x00b3a000)
libXext.so.6 => /usr/lib/libXext.so.6 (0x00b3f000)
libXrender.so.1 => /usr/lib/libXrender.so.1 (0x00b50000)
libXinerama.so.1 => /usr/lib/libXinerama.so.1 (0x00dfb000)
libXi.so.6 => /usr/lib/libXi.so.6 (0x00c9c000)
libXrandr.so.2 => /usr/lib/libXrandr.so.2 (0x00cab000)
libXcursor.so.1 => /usr/lib/libXcursor.so.1 (0x00cb3000)
libXcomposite.so.1 => /usr/lib/libXcomposite.so.1 (0x006f0000)
libXdamage.so.1 => /usr/lib/libXdamage.so.1 (0x00b59000)
libresolv.so.2 => /lib/libresolv.so.2 (0x00cbd000)
libselinux.so.1 => /lib/libselinux.so.1 (0x00ce3000)
libpixman-1.so.0 => /usr/lib/libpixman-1.so.0 (0x00e7f000)
libexpat.so.1 => /lib/libexpat.so.1 (0x00dfe000)
libxcb.so.1 => /usr/lib/libxcb.so.1 (0x068ac000)
libXau.so.6 => /usr/lib/libXau.so.6 (0x00b5c000)
///
when tell can't find xxx.so, sometimes needs a rename for shared object(.so),that is link. see below:
///
[root@bangde lib]# pwd
/usr/local/opencv-pc/lib
[root@bangde lib]# ll
total 9584
lrwxrwxrwx 1 root root 24 Feb 26 14:08 libopencv_calib3d.so -> libopencv_calib3d.so.2.3
lrwxrwxrwx 1 root root 26 Feb 26 14:08 libopencv_calib3d.so.2.3 -> libopencv_calib3d.so.2.3.0
-rwxr-xr-x. 1 root root 793676 Feb 24 14:06 libopencv_calib3d.so.2.3.0
lrwxrwxrwx 1 root root 24 Feb 26 14:08 libopencv_contrib.so -> libopencv_contrib.so.2.3
lrwxrwxrwx 1 root root 26 Feb 26 14:08 libopencv_contrib.so.2.3 -> libopencv_contrib.so.2.3.0
-rwxr-xr-x. 1 root root 294006 Feb 24 14:06 libopencv_contrib.so.2.3.0
lrwxrwxrwx 1 root root 21 Feb 26 14:08 libopencv_core.so -> libopencv_core.so.2.3
lrwxrwxrwx 1 root root 23 Feb 26 14:08 libopencv_core.so.2.3 -> libopencv_core.so.2.3.0
-rwxr-xr-x. 1 root root 2170262 Feb 24 14:06 libopencv_core.so.2.3.0
lrwxrwxrwx 1 root root 27 Feb 26 14:08 libopencv_features2d.so -> libopencv_features2d.so.2.3
lrwxrwxrwx 1 root root 29 Feb 26 14:08 libopencv_features2d.so.2.3 -> libopencv_features2d.so.2.3.0
-rwxr-xr-x. 1 root root 1131452 Feb 24 14:06 libopencv_features2d.so.2.3.0
lrwxrwxrwx 1 root root 22 Feb 26 14:08 libopencv_flann.so -> libopencv_flann.so.2.3
lrwxrwxrwx 1 root root 24 Feb 26 14:08 libopencv_flann.so.2.3 -> libopencv_flann.so.2.3.0
-rwxr-xr-x. 1 root root 34457 Feb 24 14:06 libopencv_flann.so.2.3.0
lrwxrwxrwx 1 root root 20 Feb 26 14:08 libopencv_gpu.so -> libopencv_gpu.so.2.3
lrwxrwxrwx 1 root root 22 Feb 26 14:08 libopencv_gpu.so.2.3 -> libopencv_gpu.so.2.3.0
-rwxr-xr-x. 1 root root 204764 Feb 24 14:06 libopencv_gpu.so.2.3.0
lrwxrwxrwx 1 root root 24 Feb 26 14:08 libopencv_highgui.so -> libopencv_highgui.so.2.3
lrwxrwxrwx 1 root root 26 Feb 26 14:08 libopencv_highgui.so.2.3 -> libopencv_highgui.so.2.3.0
-rwxr-xr-x. 1 root root 567146 Feb 24 14:06 libopencv_highgui.so.2.3.0
lrwxrwxrwx 1 root root 24 Feb 26 14:08 libopencv_imgproc.so -> libopencv_imgproc.so.2.3
lrwxrwxrwx 1 root root 26 Feb 26 14:08 libopencv_imgproc.so.2.3 -> libopencv_imgproc.so.2.3.0
-rwxr-xr-x. 1 root root 2006789 Feb 24 14:06 libopencv_imgproc.so.2.3.0
lrwxrwxrwx 1 root root 23 Feb 26 14:08 libopencv_legacy.so -> libopencv_legacy.so.2.3
lrwxrwxrwx 1 root root 25 Feb 26 14:08 libopencv_legacy.so.2.3 -> libopencv_legacy.so.2.3.0
-rwxr-xr-x. 1 root root 784264 Feb 24 14:06 libopencv_legacy.so.2.3.0
lrwxrwxrwx 1 root root 19 Feb 26 14:08 libopencv_ml.so -> libopencv_ml.so.2.3
lrwxrwxrwx 1 root root 21 Feb 26 14:08 libopencv_ml.so.2.3 -> libopencv_ml.so.2.3.0
-rwxr-xr-x. 1 root root 531097 Feb 24 14:06 libopencv_ml.so.2.3.0
lrwxrwxrwx 1 root root 26 Feb 26 14:08 libopencv_objdetect.so -> libopencv_objdetect.so.2.3
lrwxrwxrwx 1 root root 28 Feb 26 14:08 libopencv_objdetect.so.2.3 -> libopencv_objdetect.so.2.3.0
-rwxr-xr-x. 1 root root 400837 Feb 24 14:06 libopencv_objdetect.so.2.3.0
lrwxrwxrwx 1 root root 19 Feb 26 14:08 libopencv_ts.so -> libopencv_ts.so.2.3
lrwxrwxrwx 1 root root 21 Feb 26 14:08 libopencv_ts.so.2.3 -> libopencv_ts.so.2.3.0
-rwxr-xr-x. 1 root root 603548 Feb 24 14:06 libopencv_ts.so.2.3.0
lrwxrwxrwx 1 root root 22 Feb 26 14:08 libopencv_video.so -> libopencv_video.so.2.3
lrwxrwxrwx 1 root root 24 Feb 26 14:08 libopencv_video.so.2.3 -> libopencv_video.so.2.3.0
-rwxr-xr-x. 1 root root 263935 Feb 24 14:06 libopencv_video.so.2.3.0
drwxr-xr-x. 2 root root 4096 Feb 24 14:06 pkgconfig
drwxr-xr-x. 3 root root 4096 Feb 24 14:06 python2.7