让Clang在Windows上工作

让Clang在Windows上工作

本文介绍了让Clang在Windows上工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已遵循以下,我已经管理了一段时间后, clang来编译使用代码:blocks和MinGW。很好,所以现在我可以添加Clang模块到eclipse(为什么有一个IDE,当你可以有四个),并开始编译。

I have followed the following step by step guide and I've managed, after a bit of fiddling, to get clang to compile using code:blocks and MinGW. Great, so now I could add the Clang module to eclipse (why have one IDE when you can have four) and start compiling.

我可以编译一个不使用标准库的简单程序,但不幸的是当我尝试编译时:

I can compile a simple program that doesn't use the standard library but unfortunately when I try to compile this:

#include <iostream>
using namespace std;

int main()
{
    cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
    return 0;
}

首先我得到这个:


所以我添加Mingw头到包含路径;那么我得到这个:

so I add the Mingw headers to the include path; then I get this:

这很奇怪。为什么MingW工作,如果该文件不是位/?它是内置的编译器吗?没关系,我找到它的一个实现,并以'bits /'.

which is weird. Why does MingW work if that file isn't in 'bits/'? Is it built in to the compiler?. Never mind, I find an implementation of it and create the file in 'bits/'.

创建文件然后我得到一个错误的风暴,包括奇怪的,似乎建议clang没有正确实现预处理器,或者我对预处理器的理解不正确。

Then I get a whole storm of errors including strange ones that seem to suggest either clang doesn't implement the preprocessor correctly or else my understanding of the preprocessor is incorrect.

C:\Program Files\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++/cwchar:45:26: error: expected value in expression
#if _GLIBCXX_HAVE_WCHAR_H

等等。应该是

#if defined(_GLIBCXX_HAVE_WCHAR_H)

#ifdef _GLIBCXX_HAVE_WCHAR_H?

如果他们是那么MinGW标准库是错误的。

If they are then the MinGW standard libraries are wrong.

我假设我不正确的假设铛可以放入替换gcc,并且它不是设计为与gnu标准库一起工作。任何确认或否认,以证据支持将是最欢迎的!

I assume I'm incorrect in assuming that clang can be dropped in to replace gcc and that it is not designed to work with the gnu standard libraries. Any confirmation or denial of this, backed up with evidence would be most welcome!

那么,任何人都有一个万无一失的方式来获取cl编译在Windows PC上?有关俚语,特别是关于窗口的信息在网上很少。

So, does anybody have a foolproof way to get clang compiling on a Windows PC? There's a dearth of information online regarding clang and especially regarding windows.

我真的很想得到铛和LLVM工作,因为他们听起来伟大从我读了。任何帮助将不胜感激。

I'm really keen to get clang and LLVM working as they sound great from what I've read. Any help would be appreciated.

感谢。

推荐答案

在上构建 clang 的说明(隐藏在Clang开发边栏的一部分...)。对于MinGW,您需要On Unix-like Systems部分。唯一棘手的部分是步骤5,它告诉你如何设置C ++标准库的路径。这些需要添加到 clang / lib / Frontend / InitHeaderSearch.cpp 中的代码中。在我的机器上它起来像这样

There's some instructions for building clang on this page (hidden in the "Clang Development" part of the sidebar...). For MinGW you want the section called "On Unix-like Systems". The only tricky part is step 5 which tells you how to set up the paths for the C++ standard library. These need to be added into the code in clang/lib/Frontend/InitHeaderSearch.cpp. On my machine it wound up looking like this

// FIXME: temporary hack: hard-coded paths.
AddPath("/usr/local/include", System, true, false, false);
AddPath("c:/msysgit/mingw/bin/../lib/gcc/mingw32/4.4.0/include/c++", System, true, false, false);
AddPath("c:/msysgit/mingw/bin/../lib/gcc/mingw32/4.4.0/include/c++/mingw32", System, true, false, false);
AddPath("c:/msysgit/mingw/bin/../lib/gcc/mingw32/4.4.0/include/c++/backward", System, true, false, false);
AddPath("c:/msysgit/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../include", System, true, false, false);
AddPath("c:/msysgit/mingw/bin/../lib/gcc/mingw32/4.4.0/include", System, true, false, false);
AddPath("c:/msysgit/mingw/bin/../lib/gcc/mingw32/4.4.0/include-fixed", System, true, false, false);

但我不确定是否需要这些!

though I'm not sure all these are needed!

这篇关于让Clang在Windows上工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 00:32