将opencv1.0安装到Linux

来源:互联网 发布:24u网络机柜 编辑:程序博客网 时间:2024/06/06 06:45


对这个一点信心也没有。迷迷糊糊的开始了。胡乱的安装了好多东西。

现在步入正题

下载安装包  我下载的是opencv-1.0.0.tar  下载这个最主要的原因是因为我的软件部分在Windows下的opencv1.0中实现。现在想将编写的软件下载到硬件中。下载地址http://opencv.org/downloads.html       我的电脑配置的是redhat6

然后需要安装GTK.   安装包为gtk+-2.10.7  下载地址为http://http://ftp.gnome.org/pub/gnome/sources/gtk+/2.10/

gtk的安装浪费了很多时间。直接./configure --prefix=/usr

                                                            make 

                                                             make install

其中./configure --prefix 如果出现错误缺什么安装包就按顺序安装。切记按顺序安装。

我出现错误是在make之后错误如下:

 error: conflicting types for 'g_hash_table_get_keys'
/usr/include/glib-2.0/glib/ghash.h:98: note: previous declaration of 'g_hash_table_get_keys' was here
make[4]: *** [gtkiconfactory.lo] 错误 1
make[4]: Leaving directory `/root/下载/gtk+-2.8.20/gtk'
make[3]: *** [all-recursive] 错误 1
make[3]: Leaving directory `/root/下载/gtk+-2.8.20/gtk'
make[2]: *** [all] 错误 2
make[2]: Leaving directory `/root/下载/gtk+-2.8.20/gtk'
make[1]: *** [all-recursive] 错误 1
make[1]: Leaving directory `/root/下载/gtk+-2.8.20'
make: *** [all] 错误 2

解决办法就是静98行的信息用/*   */注释掉

然后make

make install就可以了。

可以用echo $?

如果返回0显示安装成功。如果返回其它数值就是没有安装成功。(所有的安装都可以用此命令查看)

现在进行安装opencv1.0

1.tar -xzf opencv-1.0.0.tar.gz

cp opencv-1.0.0

2.      ./config

3.   make

出现错误如下

./../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后编译成功!!!


4. make install

5. 更新动态链接库

vim 、etc/ld.so.conf在最后一行添加   /usr/local/lib

执行ldconflg 安装结束



验证安装  进入opencv-1.0.0 /samples/c

ls可以看到drawing.c文件

执行以下命令  g++ drawing.c -o drawing `pkg-config --cflags --libs opencv`

执行./drawing

就可以看到动画效果了.

0 0
原创粉丝点击