当前位置: 技术问答>linux和unix
red hat9.0下安装opencv的问题
来源: 互联网 发布时间:2015-11-03
本文导语: 我在LINUX下把OPENCV安装好了,默认路径(/usr/local/lib和/usr/local/include/opencv)下已经有lib(libcv.so等) 和.h(如cvaux.h, cv.h, highgui.h等), 运行里面的例子edge.c, 用gcc edge.c -o edge,但出来一大堆错误: edge.c:6:16: cv.h: 没有那个文件...
我在LINUX下把OPENCV安装好了,默认路径(/usr/local/lib和/usr/local/include/opencv)下已经有lib(libcv.so等) 和.h(如cvaux.h, cv.h, highgui.h等), 运行里面的例子edge.c,
用gcc edge.c -o edge,但出来一大堆错误:
edge.c:6:16: cv.h: 没有那个文件或目录
edge.c:7:21: highgui.h: 没有那个文件或目录
edge.c:14: parse error before '*' token
edge.c:14: warning: data definition has no type or storage class
edge.c: In function `on_trackbar':
edge.c:19: `CV_BLUR' undeclared (first use in this function)
edge.c:19: (Each undeclared identifier is reported only once
edge.c:19: for each function it appears in.)
edge.c: In function `main':
edge.c:36: warning: assignment makes pointer from integer without a cast
edge.c:40: request for member `width' in something not a structure or union
edge.c:40: request for member `height' in something not a structure or union
edge.c:40: `IPL_DEPTH_8U' undeclared (first use in this function)
edge.c:40: warning: assignment makes pointer from integer without a cast
edge.c:43: request for member `width' in something not a structure or union
edge.c:43: request for member `height' in something not a structure or union
edge.c:43: warning: assignment makes pointer from integer without a cast
edge.c:44: request for member `width' in something not a structure or union
edge.c:44: request for member `height' in something not a structure or union
edge.c:44: warning: assignment makes pointer from integer without a cast
edge.c:45: `CV_BGR2GRAY' undeclared (first use in this function)
我想是路径的问题,路径要怎么设置呀?
下面是安装方法:
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
default installation path is /usr/local/lib and /usr/local/include/opencv,
so you need to add /usr/local/lib to /etc/ld.so.conf (and run ldconfig after)
我是照这个弄的,可能最后一步有问题吧,,最后一步我把/usr/local/lib 加到/etc/ld.so.conf中去了,是不是要到特定目录下面去运行ldconfig这句话?
用gcc edge.c -o edge,但出来一大堆错误:
edge.c:6:16: cv.h: 没有那个文件或目录
edge.c:7:21: highgui.h: 没有那个文件或目录
edge.c:14: parse error before '*' token
edge.c:14: warning: data definition has no type or storage class
edge.c: In function `on_trackbar':
edge.c:19: `CV_BLUR' undeclared (first use in this function)
edge.c:19: (Each undeclared identifier is reported only once
edge.c:19: for each function it appears in.)
edge.c: In function `main':
edge.c:36: warning: assignment makes pointer from integer without a cast
edge.c:40: request for member `width' in something not a structure or union
edge.c:40: request for member `height' in something not a structure or union
edge.c:40: `IPL_DEPTH_8U' undeclared (first use in this function)
edge.c:40: warning: assignment makes pointer from integer without a cast
edge.c:43: request for member `width' in something not a structure or union
edge.c:43: request for member `height' in something not a structure or union
edge.c:43: warning: assignment makes pointer from integer without a cast
edge.c:44: request for member `width' in something not a structure or union
edge.c:44: request for member `height' in something not a structure or union
edge.c:44: warning: assignment makes pointer from integer without a cast
edge.c:45: `CV_BGR2GRAY' undeclared (first use in this function)
我想是路径的问题,路径要怎么设置呀?
下面是安装方法:
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
default installation path is /usr/local/lib and /usr/local/include/opencv,
so you need to add /usr/local/lib to /etc/ld.so.conf (and run ldconfig after)
我是照这个弄的,可能最后一步有问题吧,,最后一步我把/usr/local/lib 加到/etc/ld.so.conf中去了,是不是要到特定目录下面去运行ldconfig这句话?
|
gcc -I/usr/local/include/opencv -I/usr/local/lib -llibcv -L/usr/local/include/opencv edge.c -o edge
|
添加系统默认路径,编辑/etc/profile文件,在里面加入你的路径即可。里面已经有实例了,看pathmunge的行,照做就是了。
|
使用gcc -I/usr/local/include/opencv edge.c -o edge
其中,-I后面跟cv.h/highgui.h等文件所在的目录
其中,-I后面跟cv.h/highgui.h等文件所在的目录