xubuntu编译OpencV2.4.2出现make交叉编译出现错误。

假定已经有安装包。

更新软件列表,升级

sudo apt-get update
sudo apt-get upgrade

安装依赖包
sudo apt-get install build-essential libgtk2.0-dev libjpeg-dev libtiff4-dev libjasper-dev libopenexr-dev cmake python-dev python-numpy python-tk libtbb-dev libeigen2-dev yasm libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev libqt4-dev libqt4-opengl-dev sphinx-common texlive-latex-extra libv4l-dev libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev

解压
tar -xvf OpenCV-2.4.2.tar.bz2
cd OpenCV-2.4.2

创建编译目录
mkdir build
cd build

cmake生成make文件
cmake -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..


检查输出:不能有error;FFMPEG : YES;Python, TBB, OpenGL, V4L, OpenGL and Qt are detected。如果有问题要重新安装对应的包再cmake

编译(需要很长时间)
make
问题就出现在这步。。。下面看图。

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

解决方案:换一个目录解压安装OpencV

结果:


---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------



在网上找了好多类似的问题,单发先所有错误基本都是错误2跟我相同,而错误1不同,例如:

参考1:

系统:ubuntu11.10 ,opencv版本2.3.0


1.  cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local opencv-src路径

     make     #遇到下面错误:

make[2]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_ffmpeg.o] Error 1

make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2

make: *** [all] Error 2

解决办法:

通过查看make过程中的错误知道,问题出在OpenCV-2.3.0/modules/highgui/src/cap_ffmpeg_impl.hpp文件中,

参考 https://code.ros.org/trac/opencv/ticket/1020 中 ffmpeg_build.patch 和 ffmpeg_build_2.patch 对 cap_ffmpeg_impl.hpp文件中的出错变量进行替换,

为了方便,附件是改好的cap_ffmpeg_impl.hpp,可直接替换同名原文件,已经测试过成功编译。

重新执行cmake 、 make步骤,此时成功编译不再出错。然后执行sudo make install命令安装。安装过程没有出问题。


2. 在Qt中使用opencv,pro文件中添加: 

INCLUDEPATH += /usr/local/include
LIBS += /usr/local/lib/libopencv_core.so.2.3.0 /usr/local/lib/libopencv_highgui.so.2.3.0  #lib文件没列全

并在正确mian.cpp文件中正确包含头文件后build, 出现以下错误:

error: undefined reference to av_guess_codec@...............

/usr/include/opencv/cxmisc.h:516: error: ‘CV_DEPTH_MAX’ was not declared in this scope

还有很多类似的编译链接错误,省略

解决办法: 

sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg62-dev libtiff4-dev cmake libswscale-dev libjasper-dev

以上缺少什么安装什么,安装完后rebuild 运行,OK!

参考:http://www.matrixq.net/2011/10/10320.html?utm_source=rss

本参考1来源:http://blog.csdn.net/sleegod/article/details/6957965


参考二:

我的Linux系统是ubuntu11.10 ,opencv版本是2.3.1

在编译的时候遇到了

  1. 1.  cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local opencv-src路径  
  2.   
  3.      make     #遇到下面错误:  
  4.   
  5. make[2]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_ffmpeg.o] Error 1  
  6. make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2  
  7. make: *** [all] Error 2  
感谢sleegod,他也遇到了同样的问题,这里给出他的博客:
http://blog.csdn.net/sleegod/article/details/6957965

为了方便,这里贴出他的解决方法

解决办法:

通过查看make过程中的错误知道,问题出在OpenCV-2.3.0/modules/highgui/src/cap_ffmpeg_impl.hpp文件中,

参考 https://code.ros.org/trac/opencv/ticket/1020 中 ffmpeg_build.patch 和 ffmpeg_build_2.patch 对 cap_ffmpeg_impl.hpp文件中的出错变量进行替换,

为了方便,附件是改好的cap_ffmpeg_impl.hpp,可直接替换同名原文件,已经测试过成功编译。

重新执行cmake 、 make步骤,此时成功编译不再出错。然后执行sudo make install命令安装。安装过程没有出问题。


2. 在Qt中使用opencv,pro文件中添加: 

INCLUDEPATH += /usr/local/include
LIBS += /usr/local/lib/libopencv_core.so.2.3.0 /usr/local/lib/libopencv_highgui.so.2.3.0  #lib文件没列全

并在正确mian.cpp文件中正确包含头文件后build, 出现以下错误:

error: undefined reference to av_guess_codec@...............

/usr/include/opencv/cxmisc.h:516: error: ‘CV_DEPTH_MAX’ was not declared in this scope

还有很多类似的编译链接错误,省略

解决办法: 

  1. sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg62-dev libtiff4-dev cmake libswscale-dev libjasper-dev  

以上缺少什么安装什么,安装完后rebuild 运行,OK!

参考:http://www.matrixq.net/2011/10/10320.html?utm_source=rss

[附件] http://download.csdn.net/detail/sleegod/3780732

本参考二来源:http://blog.csdn.net/xizero00/article/details/7386695

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

解决方案是找到了一个国外的博客,这位朋友跟我遇到了相同的问题。

地址:http://askubuntu.com/questions/422716/opencv-build-error-cannot-open-options-file-specified-with

他的提问:

I am having trouble installing OpenCV on my machine. I run Ubuntu 12.04.

I have followed this guide: http://www.raben.com/book/export/html/3 in order to install OpenCV 2.4.3 on my linux machine. However, when I execute the

make

command, "making" stops at 14%, returns the following error

13%] Built target opencv_imgproc
[ 13%] Generating qrc_window_QT.cxx
[ 14%] Generating src/moc_window_QT.cxx
moc: Cannot open options file specified with @
Usage: moc [options] <header-file>
  -o<file>           write output to file rather than stdout
  -I<dir>            add dir to the include path for header files
  -E                 preprocess only; do not generate meta object code
  -D<macro>[=<def>]  define macro, with optional definition
  -U<macro>          undefine macro
  -i                 do not generate an #include statement
  -p<path>           path prefix for included file
  -f[<file>]         force #include, optional file name
  -nn                do not display notes
  -nw                do not display warnings
  @<file>            read additional options from file
  -v                 display version of moc
make[2]: *** [modules/highgui/src/moc_window_QT.cxx] Error 1
make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2
make: *** [all] Error 2

and then terminates. I have also installed all the required dependencies.

Thanks

下面人的回答:

If there is an accented character in the path name to the source files you may get this error. Move the source directory to a directory so that there is no accented characters in the path name. Then restart the compilation.

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

阅读更多
文章标签: opencv xubuntu
个人分类: xubuntu14.04
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

xubuntu编译OpencV2.4.2出现make交叉编译出现错误。

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭