2017-07-21 273 views
8

我想使用MinGW的在Fedora 26的交叉編譯OpenImageIO 64位Windows。在使用yum來檢索相關性的mingw版本後,我跑mingw64-cmake,然後make。但是,我馬上收到一個關於stdlib.h未找到的編譯錯誤。的MinGW /包括/ C++/cstdlib: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. 

我已經證實,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。這是一個全新的安裝,所以在那裏不應該有任何異常。

+0

出於好奇,這'G ++'版本包含在你的'mingw64'? – TriskalJM

+0

@TriskalJM gcc版本7.1.0 20170502(Fedora的MinGW的7.1.0-1.fc26) – Steve

+0

是不是有你'在/ usr/x86_64的-W64-的mingw32/SYS-根/ MinGW的一個'stdlib.h' /包括/'哪個可以通過'#include_next'找到? – ssbssa

回答

0

採用#include_next似乎導致大量的基於谷歌搜索我的問題。嘗試使用下面的語法包括直接stdlib.h:在gcc 6.0加入

-isystem /usr/x86_64-w64-ming32/sys-root/mingw/include/c++ 

這句法解決與第三方庫的問題。請參閱here的方法和推理。

編輯:更改答案,以反映有關GCC wrapper_headers和新的信息#include_next

+0

這些是GCC配置標誌。你是否建議重新編譯GCC? –

+0

我試過: 'mingw64-cmake -DCMAKE_CXX_FLAGS =' - with-gxx-include-dir =/usr/x86_64-w64-mingw32/sys-root/mingw/include/C++ --enable-version-specific-運行時-libs'' 但我收到: '無法識別的命令行選項'--with-gxx-include ...'' – Steve

+0

@TriskalJM我添加了'-isystem/usr/x86_64-w64-ming32/sys-root/mingw/include/C++ flag',用'make -n'確認g ++確實在運行該標誌,並確認'stdlib.h'在該目錄中。儘管如此,仍然會得到完全相同的錯誤。 – Steve

1

我解決了它,我可以重新編譯。

解決方案(對我來說)添加到路徑變量CPLUS_INCLUDE_PATH並將其設置爲MinGW C++ include目錄,對我來說:C:\MinGW\lib\gcc\mingw32\6.3.0\include\c++

我希望它也適合你。

相關問題