软件环境:Oracle VM Virtualbox
Fedora 9
硬件环境:tiny6410
1. 下载opencv 1.0
http://www.opencv.org.cn/index.php/Download#Version_1.02. 编译
$tar zxvf opencv-1.0.0.tar.gz.gz
$cd opencv-1.0.0
$./configure --prefix=/work/code/opencv/ --host=arm-linux --without-carbon --without-quicktime --without-1394libs --without-ffmpeg --without-python --without-swig --without-gtk --enable-static --enable-shared --disable-apps
$make
$make install
3. 安装与使用
在/work/code/opencv/目录下得到 /include /lib /share 的库文件,copy到板子中即可。
在pc上用opencv编译应用程序
export PKG_CONFIG_PATH=/work/code/opencv/lib/pkgconfig
arm-linux-g++ opencv.c -o opencv_arm `pkg-config --cflags --libs opencv`
出现的问题:
when running "make" after "./configure",
> getting the following error during make:
>
> In file included from _cxcore.h:60,
> from cxalloc.cpp:42:
> ../../cxcore/include/cxmisc.h:133:6: error : #elif with no expression
原因分析:
GCC 4.4 will introduce better checks in the preprocessor. The problem
is pretty obvious: you're using a #elif without any condition when
you really want a #else.
You can reproduce this problem with gcc-snapshot from unstable.
> Automatic build of opencv_1.0.0-6.1 on em64t by sbuild/amd64 0.53
...
> /bin/sh ../../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I../.. -I. -I../../cxcore/include -I../.. -DNDEBUG -fno-strict-aliasing -Wall -g -fopenmp -O2 -g -MT cxalloc.lo -MD -MP -MF .deps/cxalloc.Tpo -c -o cxalloc.lo cxalloc.cpp
> g++ -DHAVE_CONFIG_H -I. -I../.. -I. -I../../cxcore/include -I../.. -DNDEBUG -fno-strict-aliasing -Wall -g -fopenmp -O2 -g -MT cxalloc.lo -MD -MP -MF .deps/cxalloc.Tpo -c cxalloc.cpp -fPIC -DPIC -o .libs/cxalloc.o
> In file included from _cxcore.h:60,
> from cxalloc.cpp:42:
> ../../cxcore/include/cxmisc.h:133:6: error: #elif with no expression
> make[4]: *** [cxalloc.lo] Error 1
> make[4]: Leaving directory `/build/tbm/opencv-1.0.0/cxcore/src'
> make[3]: *** [all-recursive] Error 1
解决办法:
--- cxcore/include/cxmisc.h~ 2008-11-07 15:12:58.000000000 +0000 (删除)
+++ cxcore/include/cxmisc.h 2008-11-07 15:13:03.000000000 +0000 (打开)
@@ -130,7 +130,7 @@
#include <alloca.h>
#elif defined HAVE_ALLOCA
#include <stdlib.h>
-#elif
+#else
#error
#endif
把 #elif 改为 #else后编译成功!!!