[英]Error compiling OpenCV, fatal error: stdlib.h: No such file or directory
I'm trying to compile OpenCV.我正在尝试编译 OpenCV。 I've tried the master branch (which is currently on commit dc9602e) and version/tag 3.1.0.
我已经尝试了 master 分支(目前提交 dc9602e)和 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)).
我使用的是 Fedora 24,我首先尝试使用 Fedora 附带的 gcc(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.
我也尝试过在我的机器上编译的 GCC 6.2.0。
I'm using cmake with the following parameters:我正在使用带有以下参数的 cmake:
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=ON
cmake
runs fine and then I run make
. cmake
运行良好,然后我运行make
。 Doesn't matter the commbination of OpenCV version and gcc version, the result is the same: OpenCV版本和gcc版本的组合没有关系,结果是一样的:
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?
我该如何解决这个问题?
尝试从 cmake-gui 或使用命令行参数禁用预编译头文件
-DENABLE_PRECOMPILED_HEADERS=OFF
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从 zip 包 (opencv-2.4.11) 编译对我不起作用,但来自github repo的最新版本* 使我在 ubuntu 17.04 上成功构建
git clone https://github.com/opencv/opencv.git
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 install
Update: You might want to do git checkout 3.4
after git clone
because the master branch has many new changes since I wrote this更新:您可能想要在
git clone
之后执行git checkout 3.4
,因为自从我写这篇文章以来,master 分支有很多新的变化
Note: ffmpeg is deprecated and optional so I have used WITH_FFMPEG=OFF
flag注意:ffmpeg 已弃用且可选,因此我使用了
WITH_FFMPEG=OFF
标志
Update: I could build with ffmpeg on 18.04, used WITH_FFMPEG=ON
flag.更新:我可以在 18.04 上使用 ffmpeg 构建,使用
WITH_FFMPEG=ON
标志。 Latest ffmpeg should work with 17.04 as well.最新的 ffmpeg 也应该适用于 17.04。 Comment down if you were successful!
成功了就点个赞吧!
*OpenCV commit id cca99bf8249387da9f79be8d549b2d49e39a0289 *OpenCV 提交 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-dev
Hope 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:我在 Manjaro Linux 上,这个问题确实存在于我的系统上,因为
TBBConfig.cmake
文件是Intel-TBB
库的一部分,包含对第 56 行include
文件夹路径的路径的修改:
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.虽然
-DENABLE_PRECOMPILED_HEADERS=OFF
在我的情况下已经关闭并且没有解决问题,但似乎这个标志-DCMAKE_NO_SYSTEM_FROM_IMPORTED=ON
修复了它。
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/Transform360.dir/includes_CXX.rsp -std=c++11 -O3 -DNDEBUG -o CMakeFiles/Transform360.dir/Library/VideoFrameTransform.cpp.obj -c /home/rdp/ffmpeg-windows-build-helpers/sandbox/win64/transform360_git/Transform360/Library/VideoFrameTransform.cppCMakeFiles/Transform360.dir/Library/VideoFrameTransform.cpp.obj
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/Transform360.dir/includes_CXX.rsp and replace -isystem with -I" hint from here意思是“编辑 CMakeFiles/Transform360.dir/includes_CXX.rsp 并将 -isystem 替换为 -I”提示来自此处
For archlinux distro like Manjaro the flags -D ENABLE_PRECOMPILED_HEADERS=OFF
and -D CMAKE_NO_SYSTEM_FROM_IMPORTED=ON
fixed it with success.对于像 Manjaro 这样的 archlinux 发行版,标志
-D ENABLE_PRECOMPILED_HEADERS=OFF
和-D CMAKE_NO_SYSTEM_FROM_IMPORTED=ON
成功修复了它。
I also got problems with blas
and cblas
during compilation.我在编译过程中也遇到了
blas
和cblas
问题。 I linked cblas
by adding CMAKE_EXE_LINKER_FLAGS=-lcblas
.我挂
cblas
加入CMAKE_EXE_LINKER_FLAGS=-lcblas
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.