Ste*_*eve 7 c++ gcc mingw fedora cmake
我试图使用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.
Run Code Online (Sandbox Code Playgroud)
我已经确认stdlib.h至少在提供编译器错误的文件所在的位置/usr/include/和/usr/x86_64-w64-mingw32/sys-root/mingw/include/c++/位置找到了该位置.
为什么我仍然收到错误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:\MinGW\lib\gcc\mingw32\6.3.0\include\c++。
我希望它也适合你。
根据我的谷歌搜索,使用#include_next似乎会引起很多问题。尝试直接包含stdlib.h使用以下语法:
-isystem /usr/x86_64-w64-ming32/sys-root/mingw/include/c++
Run Code Online (Sandbox Code Playgroud)
此语法是在gcc6.0 中添加的,以解决第三方库的问题。请参阅此处了解方法和推理。
编辑:更改了答案以反映有关 gccwrapper_headers 和的新信息#include_next