mingw/include/c++/cstdlib: stdlib.h: 没有这样的文件或目录
mingw/include/c++/cstdlib: stdlib.h: No such file or directory
我正在尝试使用MinGW在Fedora 26上交叉编译64位Windows的OpenImageIO。使用yum
检索依赖项的 mingw 版本后,我运行了mingw64-cmake
然后是make
。但是,我立即收到有关找不到stdlib.h
的编译错误。
[ 0%] Built target CopyFiles
[ 0%] Building CXX object src/libutil/CMakeFiles/OpenImageIO_Util.dir/argparse.cpp.obj
In file included from .../oiio/src/libutil/argparse.cpp:36:0:
/usr/x86_64-w64-mingw32/sys-root/mingw/include/c++/cstdlib:75:15: fatal error: stdlib.h: No such file or directory
#include_next <stdlib.h>
^~~~~~~~~~
compilation terminated.
我已经确认至少在/usr/include/
和/usr/x86_64-w64-mingw32/sys-root/mingw/include/c++/
中找到了stdlib.h
,该文件也位于编译器错误的位置。
为什么我仍然收到错误stdlib.h: No such file or directory
?
更新:我做了额外的研究,并学到了以下内容:The preprocessor directive #include_next behaves like the #include directive, except that it specifically excludes the directory of the including file from the paths to be searched for the named file.
这可以解释为什么cstdlib
找不到同一文件夹中的stdlib.h
。但是cstdlib
是MinGW的一部分,而不是我试图编译的代码的任何部分。所以我仍然不知道这里出了什么问题或如何解决此错误。
编辑:这是编译器版本信息,以防万一:https://pastebin.com/PZiXS2fg。这是一个全新的安装,所以那里不应该有任何异常。
我解决了,我可以再次编译。
解决方案(对我来说(是添加变量CPLUS_INCLUDE_PATH
的路径并将其设置为 MinGW c++ 包含目录,对我来说:C:MinGWlibgccmingw326.3.0includec++
.
我希望它也对你有用。
根据我的谷歌搜索,使用#include_next
似乎会导致很多问题。尝试使用以下语法直接包含stdlib.h
:
-isystem /usr/x86_64-w64-ming32/sys-root/mingw/include/c++
此语法是在gcc
6.0 中添加的,用于解决第三方库的问题。有关方法和推理,请参阅此处。
编辑:更改了答案以反映有关 gcc wrapper_headers和#include_next
的新信息
- .cpp和.h文件中的模板专用化声明
- 为什么两个不同的未命名名称空间可以共存于一个cpp文件中
- 文本文件中的单词链表
- CMake-按正确顺序将项目与C运行时对象文件链接
- 使用新行和不使用新行读取文件
- 在C++程序中输入的文本文件将不起作用,除非文本被复制和粘贴
- 挂起和取消挂起一个文件DLL
- 如何确定我已使用非编码文件到达 EOF?
- 命名空间中具有.h和.cpp文件的类
- 如何使用ndk-build.cmd构建Android.so文件
- 从包含m行的文件中提取n行,必要时(惰性地)重复该文件
- 读取文件并输入到矢量中
- 在C++中查找文件
- c++库的公共头文件中应该包含什么
- 用c++从输入文件中读取另一行
- Cppcheck生成xml转储文件
- 读取文件的最后一行并输入到链接列表时出错
- 无法编译 rtmidi 测试 cmidiin.cpp 文件, 非法指令
- 如何将内容数组写入文本文件?
- C++ Windows 驱动程序MSB3030无法复制该文件,因为它找不到