+ -
当前位置:首页 → 问答吧 → OPENCV的在LINUX下的安装使用注意事项

OPENCV的在LINUX下的安装使用注意事项

时间:2008-04-08

来源:互联网

经过几天的努力(快一个星期了。),终于把OPENCV装到LINUX下并且里边的程序可以正常使用了。本来就应该可以顺利完成的东西,不过,其中遇到很多困难也是不争的事实。

总结以下几点注意事项,希望对以后的工作有所帮助:(按照OPENCV网站上的步骤安装会出现问题)

1.安装RH9时记得把GTK+安装上,否则,OPENCV里边所有程序是执行不了的。

2.记得修改/etc/ld.so.conf
添加一行/usr/local/lib

# ldconfig (root用户)

然后将/usr/local/lib/pkg-config中的opencv.pc 拷贝到/usr/lib/pkg-config中,(如果不做这步,根本编译不起)

可以采用这个操作
# cp /usr/local/lib/pkg-config/opencv.pc /usr/lib/pkg-config

3. congfigure的时候,输入./configure --without-python --enable-static

注释:在我的电脑上,如果没有第一个WITHOUT,MAKE的时候就会出错,无奈;第二个是为了在编译程序的时候生成静态连接库文件(具体怎么生成我还没搞懂,新手。。。)

之后,出现的提示信息是:
./configure
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... no
... ...

General configuration ==============

Compiler:       g++

CXXFLAGS:       -Wall -fno-rtti -pipe -O3 -g -march=i686 -ffast-math -fomit-frame-pointer

Install path:     /usr/local

HighGUI configuration ==================

Windowing system --------------
Use Carbon / Mac OS X:    no
Use gtk+ 2.x:             yes
Use gthread:              yes

Image I/O ---------------------
Use libjpeg:              yes
Use zlib:                 yes
Use libpng:               yes
Use libtiff:              yes
Use libjasper:            no
Use libIlmImf:            no

Video I/O ---------------------
Use QuickTime / Mac OS X: no
Use xine:                 no
Use ffmpeg:               no
Use dc1394 & raw1394:     no
Use v4l:                  yes
Use v4l2:                 no

Wrappers for other languages =============

SWIG                     
Python                    yes

Additional build settings ============

Build demo apps           yes

Now run make ...

与网上的不太一样,也许今后工作会因为这个问题而导致无法前进。

4.还要注意把OPENCV下的头文件,就是包含cv.h和highgui.h这个2个文件的那个目录里边的所有文件(记得是/usr/local/include/opencv),都拷贝到/usr/include下(别问我为什么,反正不拷贝,编译程序时提示找不到那2个头文件)

5.编译链接文件的方法:

以编辑cvtest.c文件为例子(因为highgui中采用了c++,所以一定要用g++编译才可以)

A. g++ `pkg-config --cflags opencv` -o cvtest cvtest.c `pkg-config --libs opencv`

B. 编译: g++ `pkg-config --cflags opencv` -c cvtest.c

链接: g++ `pkg-config --libs opencv` -o cvtest cvtest.o

注意:g++ 后边那个东西是 ` ,就是ESC下边那个键。

作者: lanterns   发布时间: 2008-04-08

多谢多谢~

作者: sunseasun   发布时间: 2011-05-19

这次我看清了。。是个08年的坟又被挖了。。

作者: sjwkwang_   发布时间: 2011-05-19