/usr/include/c++/7/cstdlib:75:15: fatal error: stdlib.h: No such file or directory

这里写自定义目录标题

  • Ubuntu 18.04编译opencv-3.2.0时出现如下错误:
  • 原因分析:
  • 解决方法:

Ubuntu 18.04编译opencv-3.2.0时出现如下错误:

[ 20%] Generating precomp.hpp.gch/opencv_viz_Release.gch
In file included from /usr/include/c++/7/ext/string_conversions.h:41:0,
                 from /usr/include/c++/7/bits/basic_string.h:6361,
                 from /usr/include/c++/7/string:52,
                 from /usr/include/c++/7/stdexcept:39,
                 from /usr/include/c++/7/array:39,
                 from /usr/include/c++/7/tuple:39,
                 from /usr/include/c++/7/bits/stl_map.h:63,
                 from /usr/include/c++/7/map:61,
                 from /home/hri/MyInstallSoftware/opencv-3.2.0/build/modules/viz/precomp.hpp:49:
/usr/include/c++/7/cstdlib:75:15: fatal error: stdlib.h: No such file or directory
 #include_next 
               ^~~~~~~~~~
compilation terminated.
modules/viz/CMakeFiles/pch_Generate_opencv_viz.dir/build.make:62: recipe for target 'modules/viz/precomp.hpp.gch/opencv_viz_Release.gch' failed
make[2]: *** [modules/viz/precomp.hpp.gch/opencv_viz_Release.gch] Error 1
CMakeFiles/Makefile2:3122: recipe for target 'modules/viz/CMakeFiles/pch_Generate_opencv_viz.dir/all' failed
make[1]: *** [modules/viz/CMakeFiles/pch_Generate_opencv_viz.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

原因分析:

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

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

解决方法:

在编译opecv-3.2.0时,加入如下选项:

-DENABLE_PRECOMPILED_HEADERS=OFF

你可能感兴趣的:(Ubuntu,相关软件安装,opencv)