1.安装RH9时记得把GTK+安装上,否则,OPENCV里边所有程序是执行不了的。 (包括转贴)
Linux
=====
There are no prebuilt binaries for Linux version (because of different C++-incompatible versions of GCC in different distributions), so you'd have to build it from sources. The following has been tested on Slackware 10.0 (GCC 3.3.*) That's what you need to build fully-functionaly libraries and demos:
======
+GTK+ 2.x or higher.
+ libpng, libjpeg and libtiff with development files.
+ libavcodec from ffmpeg 0.4.8 + headers. Earlier version do not work with OpenCV because of different API. libavcodec is LGPL software, so to use it with non-GPL software (such as OpenCV) you need to build and use a _shared_ library libavcodec.so.*: get ffmpeg-0.4.8 from ffmpeg.sourceforge.net ./configure --enable-shared make make install you will have got: /usr/local/lib/libavcodec.so.* & /usr/local/include/ffmpeg/*.h Now build OpenCV:
======
b) if your distribution does not support RPM, build and install it in Unix/Linux traditional way:
./configure
make
make install # as root
ldconfig # as root
在上面这段中,要确认安装系统时安装了GTK,之后安装ffmpeg(可以在http://download.chinaunix.net/download/0003000/2990.shtml)中下载.
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
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下边那个键。