I'm trying to compile OpenCV. I've tried the master branch (which is currently on commit dc9602e) and version/tag 3.1.0. I'm using Fedora 24, I first tried using gcc that comes with Fedora (gcc (GCC) 6.2.1 20160916 (Red Hat 6.2.1-2)). I have also tried with GCC 6.2.0, compiled on my machine.
I'm using cmake with the following parameters:
cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_NEW_PYTHON_SUPPORT=ON -DINSTALL_PYTHON_EXAMPLES=ON -DWITH_TBB=ON -DWITH_V4L=ON -DINSTALL_C_EXAMPLES=ON -DBUILD_EXAMPLES=ON -DWITH_QT=ON -DWITH_OPENGL=ON -DWITH_OPENCL=ON -DWITH_EIGEN=ON -DWITH_OPENEXR=ONcmake runs fine and then I run make. Doesn't matter the commbination of OpenCV version and gcc version, the result is the same:
In file included from /usr/local/include/c++/6.2.0/bits/stl_algo.h:59:0, from /usr/local/include/c++/6.2.0/algorithm:62, from /home/dmelo/proj2/opencv/modules/core/include/opencv2/core/base.hpp:55, from /home/dmelo/proj2/opencv/modules/core/include/opencv2/core.hpp:54, from /home/dmelo/proj2/opencv/modules/highgui/include/opencv2/highgui.hpp:46, from /home/dmelo/proj2/opencv/build/modules/highgui/precomp.hpp:45:
/usr/local/include/c++/6.2.0/cstdlib:75:25: fatal error: stdlib.h: No such file or directory #include_next <stdlib.h> ^
compilation terminated.Is anyone else experiencing this? How can I solve this problem?
35 Answers
Try by disabling pre-compiled headers, either from cmake-gui or using the command line parameter
-DENABLE_PRECOMPILED_HEADERS=OFF 1 Compiling from zip package (opencv-2.4.11) did not work for me but the latest version* from github repo gave me a successful build on ubuntu 17.04
git clone
cd opencv
mkdir mybin
cd mybin
cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local -DENABLE_PRECOMPILED_HEADERS=OFF -DWITH_FFMPEG=OFF ..
make
sudo make installUpdate: You might want to do git checkout 3.4 after git clone because the master branch has many new changes since I wrote this
Note: ffmpeg is deprecated and optional so I have used WITH_FFMPEG=OFF flag
Update: I could build with ffmpeg on 18.04, used WITH_FFMPEG=ON flag. Latest ffmpeg should work with 17.04 as well. Comment down if you were successful!
*OpenCV commit id cca99bf8249387da9f79be8d549b2d49e39a0289
Additional info: Dependencies I installed before compiling-
build-essential cmake git libgtk2.0-dev pkg-config python-dev python-numpy libavcodec-dev libavformat-dev libswscale-dev libjpeg-dev libpng-dev libtiff-dev libdc1394-22-dev libtbb2 libtbb-devHope this helps someone in future!
I am on Manjaro Linux and this problem do exists on my system because of TBBConfig.cmake file which is a part of Intel-TBB library and contains modification to path of include folder path at line 56:
set_target_properties(TBB::${_tbb_component} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_LIST_DIR}/../../../include")While -DENABLE_PRECOMPILED_HEADERS=OFF was already off in my case and didn't fix the issue, it seems that this flag -DCMAKE_NO_SYSTEM_FROM_IMPORTED=ON fixes it.
For archlinux distro like Manjaro the flags -D ENABLE_PRECOMPILED_HEADERS=OFF and -D CMAKE_NO_SYSTEM_FROM_IMPORTED=ON fixed it with success.
I also got problems with blas and cblas during compilation.
I linked cblas by adding CMAKE_EXE_LINKER_FLAGS=-lcblas.
For me this:
[ 33%] Building CXX object
/home/rdp/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/bin/x86_64-w64-mingw32-g++ @CMakeFiles/ -std=c++11 -O3 -DNDEBUG -o CMakeFiles/ -c /home/rdp/ffmpeg-windows-build-helpers/sandbox/win64/transform360_git/Transform360/Library/
In file included from /home/rdp/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/include/c++/8.2.0/ext/string_conversions.h:41, from /home/rdp/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/include/c++/8.2.0/bits/basic_string.h:6391, from /home/rdp/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/include/c++/8.2.0/string:52, from /home/rdp/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/include/c++/8.2.0/stdexcept:39, from /home/rdp/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/include/c++/8.2.0/array:39, from /home/rdp/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/include/c++/8.2.0/tuple:39, from /home/rdp/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/include/c++/8.2.0/bits/stl_map.h:63, from /home/rdp/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/include/c++/8.2.0/map:61, from /home/rdp/ffmpeg-windows-build-helpers/sandbox/win64/transform360_git/Transform360/Library/VideoFrameTransform.h:18, from /home/rdp/ffmpeg-windows-build-helpers/sandbox/win64/transform360_git/Transform360/Library/VideoFrameTransform.cpp:14:
/home/rdp/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/include/c++/8.2.0/cstdlib:75:15: fatal error: stdlib.h: No such file or directory #include_next <stdlib.h> ^~~~~~~~~~
compilation terminated.meant "edit CMakeFiles/ and replace -isystem with -I" hint from here
1