Windows上的Msys2和Clang:未找到iostream文件

时间:2017-02-21 20:26:05

标签: clang c++14 iostream msys2

我按照本教程(here)让Clang在Windows上工作。我选择与msys2一起安装clang的路径。

按照所有指示后,我编写了简单的程序:

#include <iostream>
using namespace std;

int main()
{   
cout<<"Hello, World!\n";
return 0;
}

编译后: clang ++ Helloworld.cpp -o Helloworld.exe -std = c ++ 14

我收到错误:

  

* Helloworld.cpp:2:10:致命错误:'找不到'iostream'文件,

     

生成了1个错误。*

在我得到的命令行中添加-v:

Errors

clang version 3.9.1 (tags/RELEASE_391/final) 
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: C:\msys64\mingw64\bin     
"C:\\msys64\\mingw64\\bin\\clang++.exe" -cc1 -triple x86_64-w64-windows-gnu -emit-obj -mrelax-all -disable-free -disable-    llvm-verifier -discard-value-names -main-file-name Helloworld.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -momit-leaf-frame-pointer -v -dwarf-column-info -debugger-tuning=gdb -resource-dir "C:\\msys64\\mingw64\\bin\\..\\lib\\clang\\3.9.1" -internal-isystem "C:\\msys64\\mingw64\\x86_64-w64-mingw32\\include\\c++" -internal-isystem "C:\\msys64\\mingw64\\x86_64-w64-mingw32\\include\\c++\\x86_64-w64-mingw32" -internal-isystem "C:\\msys64\\mingw64\\x86_64-w64-mingw32\\include\\c++\\backward" -internal-isystem "C:\\msys64\\mingw64\\x86_64-w64-mingw32\\include\\c++\\" -internal-isystem "C:\\msys64\\mingw64\\x86_64-w64-mingw32\\include\\c++\\\\x86_64-w64-mingw32" -internal-isystem "C:\\msys64\\mingw64\\x86_64-w64-mingw32\\include\\c++\\\\backward" -internal-isystem "C:\\msys64\\mingw64\\include\\c++\\" -internal-isystem "C:\\msys64\\mingw64\\include\\c++\\\\x86_64-w64-mingw32" -internal-isystem "C:\\msys64\\mingw64\\include\\c++\\\\backward" -internal-isystem "include\\c++" -internal-isystem "include\\c++\\x86_64-w64-mingw32" -internal-isystem "include\\c++\\backward" -internal-isystem "C:\\msys64\\mingw64\\bin\\..\\lib\\clang\\3.9.1\\include" -internal-isystem "C:\\msys64\\mingw64\\x86_64-w64-mingw32\\include" -internal-isystem "C:\\msys64\\mingw64\\include" -std=c++14 -fdeprecated-macro -fdebug-compilation-dir "C:\\msys64\\programming" -ferror-limit 19 -fmessage-length 0 -femulated-tls -fno-use-cxa-atexit -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -o "C:\\msys64\\tmp\\Helloworld-2393e7.o" -x c++ Helloworld.cpp

clang -cc1 version 3.9.1 based upon LLVM 3.9.1 default target x86_64-w64-windows-gnu
ignoring nonexistent directory "C:\msys64\mingw64\x86_64-w64-mingw32\include\c++"
ignoring nonexistent directory "C:\msys64\mingw64\x86_64-w64-mingw32\include\c++\x86_64-w64-mingw32"
ignoring nonexistent directory "C:\msys64\mingw64\x86_64-w64-mingw32\include\c++\backward"
ignoring nonexistent directory "C:\msys64\mingw64\x86_64-w64-mingw32\include\c++\"
ignoring nonexistent directory "C:\msys64\mingw64\x86_64-w64-mingw32\include\c++\\x86_64-w64-mingw32"
ignoring nonexistent directory "C:\msys64\mingw64\x86_64-w64-mingw32\include\c++\\backward"
ignoring nonexistent directory "C:\msys64\mingw64\include\c++\"
ignoring nonexistent directory "C:\msys64\mingw64\include\c++\\x86_64-w64-mingw32"
ignoring nonexistent directory "C:\msys64\mingw64\include\c++\\backward"
ignoring nonexistent directory "include\c++"
ignoring nonexistent directory "include\c++\x86_64-w64-mingw32"
ignoring nonexistent directory "include\c++\backward"
ignoring nonexistent directory "C:\msys64\mingw64\x86_64-w64-mingw32\include"
#include "..." search starts here:
#include <...> search starts here:
 C:\msys64\mingw64\bin\..\lib\clang\3.9.1\include
 C:\msys64\mingw64\include
End of search list.
Helloworld.cpp:2:10: fatal error: 'iostream' file not found
#include <iostream>
         ^
1 error generated.

如何让系统找到iostream?我读到了一些内容,你必须指向clang / lib / Frontend / InitHeaderSearch.cpp中的mingw标题。我在计算机上找不到文件InitHeaderSearch.cpp。

感谢您的帮助。

Windows 8 Clang 3.9.1

1 个答案:

答案 0 :(得分:0)

由于构建脚本中的错误,缺少某些依赖项。

安装gcc软件包(32位为mingw-w64-i686-gcc,64位为mingw-w64-x86_64-gcc)将拉出它们。