linux安装opencv时make又出错

[ 12%] Built target gen-pkgconfig
[ 12%] Built target libwebp
[ 12%] Built target ippiw
[ 12%] Building CXX object 3rdparty/protobuf/CMakeFiles/libprotobuf.dir/src/google/protobuf/extension_set.cc.o
In file included from /home/w/opencv/3rdparty/protobuf/src/google/protobuf/repeated_field.h:62,
from /home/w/opencv/3rdparty/protobuf/src/google/protobuf/extension_set.h:51,
from /home/w/opencv/3rdparty/protobuf/src/google/protobuf/extension_set.cc:38:

3rdparty/protobuf/CMakeFiles/libprotobuf.dir/build.make:110: recipe for target '3rdparty/protobuf/CMakeFiles/libprotobuf.dir/src/google/protobuf/extension_set.cc.o' failed
make[2]: *** [3rdparty/protobuf/CMakeFiles/libprotobuf.dir/src/google/protobuf/extension_set.cc.o] Error 1
CMakeFiles/Makefile2:436: recipe for target '3rdparty/protobuf/CMakeFiles/libprotobuf.dir/all' failed
make[1]: *** [3rdparty/protobuf/CMakeFiles/libprotobuf.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2

https://blog.csdn.net/huihut/article/details/78701814
看其中 多线程编译错误信息不明确

使用的是什么命令编译在什么环境下编译呢,不建议使用多线程编译。

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

推荐的修复方法是不要把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

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对gcc6支持不完善,导致gcc不兼容OpenCV

**

解决方法:卸载Ubuntu 16,使用Ubuntu 14**