OpenCV Linux 安装 Make出错

Posted Benedict97

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了OpenCV Linux 安装 Make出错相关的知识,希望对你有一定的参考价值。

执行完CMake之后再执行make时遇到以下错误

 1 [  6%] Generating precomp.hpp.gch/opencv_core_Release.gch
 2 In file included from /usr/include/c++/6/bits/stl_algo.h:59:0,
 3                  from /usr/include/c++/6/algorithm:62,
 4                  from /opt/opencv/opencv-3.1.0/modules/core/include/opencv2/core/base.hpp:53,
 5                  from /opt/opencv/opencv-3.1.0/modules/core/include/opencv2/core.hpp:54,
 6                  from /opt/opencv/opencv-3.1.0/modules/core/include/opencv2/core/utility.hpp:52,
 7                  from /opt/opencv/build/modules/core/precomp.hpp:49:
 8 /usr/include/c++/6/cstdlib:75:25: fatal error: stdlib.h: 没有那个文件或目录
 9  #include_next <stdlib.h>
10                          ^
11 compilation terminated.
12 modules/core/CMakeFiles/pch_Generate_opencv_core.dir/build.make:62: recipe for target modules/core/precomp.hpp.gch/opencv_core_Release.gch failed
13 make[2]: *** [modules/core/precomp.hpp.gch/opencv_core_Release.gch] Error 1
14 CMakeFiles/Makefile2:1178: recipe for target modules/core/CMakeFiles/pch_Generate_opencv_core.dir/all failed
15 make[1]: *** [modules/core/CMakeFiles/pch_Generate_opencv_core.dir/all] Error 2
16 Makefile:160: recipe for target all failed
17 make: *** [all] Error 2

这是由于gcc6已经吧stdlib.h纳入了libstdc++以进行更好的优化,C Library的头文件stdlib.h使用 Include_next,而include_next对哦草错系统头文件路径很敏感。

推荐的修复方法是不要把include路径作为系统目录,而是使用标准方式包含include 目录

 

翻译自 https://bugs.webkit.org/show_bug.cgi?id=161697

 

原文说明:

Trying to build WebKitGTK+ with GCC 6 I got this error:

In file included from /home/igalia/clopez/yocto/commit-builds/meta-webkit/builds/qemux86-64/tmp-glibc/sysroots/qemux86/usr/include/c++/6.2.0/ext/string_conversions.h:41:0,
                 from /home/igalia/clopez/yocto/commit-builds/meta-webkit/builds/qemux86-64/tmp-glibc/sysroots/qemux86/usr/include/c++/6.2.0/bits/basic_string.h:5402,
                 from /home/igalia/clopez/yocto/commit-builds/meta-webkit/builds/qemux86-64/tmp-glibc/sysroots/qemux86/usr/include/c++/6.2.0/string:52,
                 from /home/igalia/clopez/yocto/commit-builds/meta-webkit/builds/qemux86-64/tmp-glibc/work/i586-oe-linux/webkitgtk/2.12.5-r0/webkitgtk-2.12.5/Source/ThirdParty/ANGLE/src/common/debug.h:14,
                 from /home/igalia/clopez/yocto/commit-builds/meta-webkit/builds/qemux86-64/tmp-glibc/work/i586-oe-linux/webkitgtk/2.12.5-r0/webkitgtk-2.12.5/Source/ThirdParty/ANGLE/src/common/mathutil.h:12,
                 from /home/igalia/clopez/yocto/commit-builds/meta-webkit/builds/qemux86-64/tmp-glibc/work/i586-oe-linux/webkitgtk/2.12.5-r0/webkitgtk-2.12.5/Source/ThirdParty/ANGLE/src/common/mathutil.cpp:9:
/home/igalia/clopez/yocto/commit-builds/meta-webkit/builds/qemux86-64/tmp-glibc/sysroots/qemux86/usr/include/c++/6.2.0/cstdlib:75:25: fatal error: stdlib.h: No such file or directory
 #include_next <stdlib.h>

The issue seems to be that GCC 6 has now introduced stdlib.h in libstdc++ for better compliance and its including the C library stdlib.h using include_next which is sensitive to order of system header include paths. See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70129

The recommended way to fix this is to stop adding include directories as system ones (-isystem) and instead use the standard way to include directories (-I)

The openembedded project is carrying this downstream patch against WebKitGTK+ 2.12 with the above fix: http://git.openembedded.org/openembedded-core/tree/meta/recipes-sato/webkit/files/0001-WebKitMacros-Append-to-I-and-not-to-isystem.patch

 


以上是关于OpenCV Linux 安装 Make出错的主要内容,如果未能解决你的问题,请参考以下文章

opencv--linux下安装

Linux中安装opencv-3.3.1

cmake编译opencv总是出错 求助啊

用mingw32-make 对opencv进行make时,出错,接着mingw32-make install也出错,不知道问题在哪儿?

linux 源代码程序终端安装make后出现 make: *** 没有指明目标并且找不到 makefile。 停止。

linux下cmake编译opencv 为啥这么慢