【发布时间】:2017-07-21 20:06:06
【问题描述】:
我正在尝试使用 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。这是一个全新的安装,所以应该不会有任何异常。
【问题讨论】:
-
出于好奇,您的
mingw64中包含哪个g++版本? -
@TriskalJM gcc 版本 7.1.0 20170502 (Fedora MinGW 7.1.0-1.fc26)
-
您的
/usr/x86_64-w64-mingw32/sys-root/mingw/include/中没有stdlib.h会被#include_next找到吗? -
听起来很糟糕。如果你只编译
#include <cstdlib>和g++ -c,或者只编译#include <stdlib.h>和gcc -c,它会找到它吗? -
@ssbsa 我也想知道。但是,从
CMakeFile中删除-isystem似乎可以解决问题。之后我遇到的新错误只是通过消除oiio/src/include/OpenImageIO/missing_math.h中不必要的 Win32 特定定义来解决。现在没有更多的错误,它似乎可以编译。感谢您的提示!仍然需要弄清楚-isystem的来源以及如何解决这个问题,而不必在 cmake 之后直接编辑 CMakeFiles,这可以变成答案。
标签: c++ gcc cmake mingw fedora