1

I'm trying to make OpenCV 3.1 after I generate the build with cmake-gui. I get this error

[ 16%] Generating precomp.hpp.gch/opencv_core_Release.gch
In file included from /usr/include/c++/7/bits/stl_algo.h:59:0,
             from /usr/include/c++/7/algorithm:62,
             from /home/demgall/Documents/OpenCV/opencv-3.1.0/modules/core/include/opencv2/core/base.hpp:53,
             from /home/demgall/Documents/OpenCV/opencv-3.1.0/modules/core/include/opencv2/core.hpp:54,
             from /home/demgall/Documents/OpenCV/opencv-3.1.0/modules/core/include/opencv2/core/utility.hpp:52,
             from /home/demgall/Documents/OpenCV/release/modules/core/precomp.hpp:49:
/usr/include/c++/7/cstdlib:75:15: fatal error: stdlib.h: No such file or directory
 #include_next <stdlib.h>
           ^~~~~~~~~~
compilation terminated.
modules/core/CMakeFiles/pch_Generate_opencv_core.dir/build.make:62: recipe for target 'modules/core/precomp.hpp.gch/opencv_core_Release.gch' failed
make[2]: *** [modules/core/precomp.hpp.gch/opencv_core_Release.gch] Error 1
CMakeFiles/Makefile2:1402: recipe for target 'modules/core/CMakeFiles/pch_Generate_opencv_core.dir/all' failed
make[1]: *** [modules/core/CMakeFiles/pch_Generate_opencv_core.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2

I don't know what other information I can handle. Just ask me what you need and I'll give it.

1 Answer 1

0

I haven't fully dug into what's actually happening but basically gcc can't find some of the system header files when building the PCH related code.

The PCH support CMake file (cmake/OpenCVPCHSupport.cmake) uses gcc's -isystem flag to set the directories where header files will be looked for and it looks like the compiler is getting a bit confused with that...

A simple solution that I found was to replace the -isystem with -I. You can make this change with the following command:

sed -i '/_PCH_isystem_prefix/ s/"-isystem"/"-I"/' cmake/OpenCVPCHSupport.cmake

That solves the issue on version 3.1.0, using gcc 6.5.0

See the gcc docs for more info about the difference between these and other similar flags.

1
  • Just see this after a long hols break :) comment updated.
    – nicopernas
    Sep 9, 2019 at 14:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .