Ask Your Question

ubuntu 16.10, OpenCV build fails - stdlib.h missing

asked 2016-12-04 12:00:11 -0600

Alice gravatar image

updated 2016-12-04 12:01:52 -0600


I'm trying to build OpenCV on Ubuntu 16.10. The build process is interrupted with the error shown below.

Obviously the file "/usr/include/c++/6/stdlib.h" exists in my system. I have tried this with: OpenCV master branch, OpenCV 3.1.0, 3.0.0, 2.4.13.

Could you please give me some clues what can cause this error and how to solve it? All ideas are welcome :)

[ 16%] Building CXX object modules/imgcodecs/CMakeFiles/opencv_imgcodecs.dir/src/bitstrm.cpp.o
[ 16%] Building CXX object modules/imgcodecs/CMakeFiles/opencv_imgcodecs.dir/src/rgbe.cpp.o
[ 16%] Building CXX object modules/imgcodecs/CMakeFiles/opencv_imgcodecs.dir/src/exif.cpp.o
[ 16%] Linking CXX shared library ../../lib/
[ 16%] Built target opencv_imgcodecs
Scanning dependencies of target opencv_highgui_automoc
[ 16%] Automatic moc for target opencv_highgui
Generating moc_window_QT.cpp
[ 16%] Built target opencv_highgui_automoc
Scanning dependencies of target opencv_highgui_pch_dephelp_automoc
[ 16%] Automatic moc for target opencv_highgui_pch_dephelp
[ 16%] Built target opencv_highgui_pch_dephelp_automoc
Scanning dependencies of target opencv_highgui_pch_dephelp
[ 16%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui_pch_dephelp.dir/opencv_highgui_pch_dephelp.cxx.o
[ 16%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui_pch_dephelp.dir/opencv_highgui_pch_dephelp_automoc.cpp.o
[ 16%] Linking CXX static library ../../lib/libopencv_highgui_pch_dephelp.a
[ 16%] Built target opencv_highgui_pch_dephelp
Scanning dependencies of target pch_Generate_opencv_highgui
[ 16%] Generating precomp.hpp
[ 16%] Generating precomp.hpp.gch/opencv_highgui_RELEASE.gch
In file included from /usr/include/c++/6/bits/stl_algo.h:59:0,
                 from /usr/include/c++/6/algorithm:62,
                 from /home/alice/opencv/opencv-master/modules/core/include/opencv2/core/base.hpp:55,
                 from /home/alice/opencv/opencv-master/modules/core/include/opencv2/core.hpp:54,
                 from /home/alice/opencv/opencv-master/modules/highgui/include/opencv2/highgui.hpp:46,
                 from /home/alice/opencv/opencv-master/build/modules/highgui/precomp.hpp:45:
/usr/include/c++/6/cstdlib:75:25: fatal error: stdlib.h: No such file or directory
 #include_next <stdlib.h>
compilation terminated.
modules/highgui/CMakeFiles/pch_Generate_opencv_highgui.dir/build.make:62: recipe for target 'modules/highgui/precomp.hpp.gch/opencv_highgui_RELEASE.gch' failed
make[2]: *** [modules/highgui/precomp.hpp.gch/opencv_highgui_RELEASE.gch] Error 1
CMakeFiles/Makefile2:4061: polecenia dla obiektu 'modules/highgui/CMakeFiles/pch_Generate_opencv_highgui.dir/all' failed
make[1]: *** [modules/highgui/CMakeFiles/pch_Generate_opencv_highgui.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2
edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted

answered 2016-12-08 08:19:04 -0600

berak gravatar image

it's a bug in the cmake files, which was fixed a month ago

please try to get latest github master branch (not 3.1.0 release)

edit flag offensive delete link more



Could you please confirm that the fix is working with a few more lines on the latest github master. I (a.k.a. newbie) downloaded the files yesterday and experienced the identical error?

My issue. I used the wrong repository. Everything worked fine based on your instructions, Berak. Thx.

Matha gravatar imageMatha ( 2016-12-10 19:49:31 -0600 )edit

thank you for confirming this ;)

berak gravatar imageberak ( 2016-12-10 23:38:04 -0600 )edit

@berak thank you for your answer. The problem which I described still occurs. I hace tried that with master branch on 2016.12.02 and again - today (2016.12.26).

Alice gravatar imageAlice ( 2016-12-26 16:50:48 -0600 )edit

answered 2016-12-26 16:56:25 -0600

Alice gravatar image

updated 2016-12-26 17:02:51 -0600

Problem still exists in master branch. The solution which i have found is described here:

In short:

  • solution 1:
    Configure compilation process with following parameter:


  • solution 2:
    Patch the cmake file (see link above for details).
edit flag offensive delete link more


in case someone get ffmpeg_codecs.hpp error: ‘CODEC_ID_H264’ was not declared in this scope, you can add -D WITH_FFMPEG=OFF to your make

didxga gravatar imagedidxga ( 2017-09-14 02:12:21 -0600 )edit

In which file should I put the following line cmake -DENABLE_PRECOMPILED_HEADERS = OFF?

And in which folder do I find that file?

retg096 gravatar imageretg096 ( 2019-04-23 18:59:07 -0600 )edit

@retg096 please do not post answers here, if you have a question or a comment, thank you.

(and it is a cmake cmdline option)

berak gravatar imageberak ( 2019-04-24 01:18:24 -0600 )edit

Question Tools

1 follower


Asked: 2016-12-04 12:00:11 -0600

Seen: 7,387 times

Last updated: Dec 26 '16