错误在Windows上使用Clang编译C 11程序
error compiling c++11 program with clang on windows
我已经在Windows上构建了Clang 3.2,并试图构建一个简单的Hello World程序。但是我遇到了很多错误,就像下面看到的那样。
d:Mariusxyz>clang++ -stdlib=libc++ -std=c++11 -Wall xyz.cpp -o xyz.exe
clang++: warning: argument unused during compilation: '-stdlib=libc++'
In file included from xyz.cpp:12:
In file included from ./stdafx.h:18:
In file included from C:Program Files (x86)Microsoft Visual Studio 11.0VCincludealgorithm:6:
In file included from C:Program Files (x86)Microsoft Visual Studio 11.0VCincludexmemory:6:
In file included from C:Program Files (x86)Microsoft Visual Studio 11.0VCincludexmemory0:9:
In file included from C:Program Files (x86)Microsoft Visual Studio 11.0VCincludexutility:8:
In file included from C:Program Files (x86)Microsoft Visual Studio 11.0VCincludeutility:8:
C:Program Files (x86)Microsoft Visual Studio 11.0VCincludetype_traits:1072:
33: error:
'_Ty' does not refer to a value
_HAS_TRIVIAL_MOVE_CONSTRUCTOR(_Ty)
^
...
C:Program Files (x86)Microsoft Visual Studio 11.0VCincludexstddef:540:50: note:
expanded from macro '_VARIADIC_EXPAND_4'
#define _VARIADIC_EXPAND_4(FUNC, X1, X2, X3, X4)
^
C:Program Files (x86)Microsoft Visual Studio 11.0VCincludexrefwrap:222:22:note:
expanded from macro '_CLASS_RESULT_OF_PMF_OPT_0X'
__thiscall, X2, X3, X4)
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
我遇到了很多这样的错误,来自VC 2012标题。Windows上的clang 是否有可能在Windows上构建C 11代码?我必须提供其他命令开关吗?
clang在由Visual Studio构建时无法正常工作(据说它是由MingW构建时起作用的,但我无法验证自己)。
构建Clang时,它被配置为使用用于构建它的库。由于您使用Visual Studio构建了Clang,因此Clang将尝试使用Visual Studio标题和库。不幸的是,Clang和Visual Studio的内部与Clang 无法使用VS特定的标头。
直到可以为Windows编译LIBC 之前,Clang(几乎可以肯定)在由Visual Studio编译时将永远无法使用。尝试使用mingw构建它(并撰写博客文章或有关您的工作方式!),看看它是否对您有用。
clang默认值为用于构建它的工具链的包含。但是,与MS一样,扩展也可能是供应商特定的。Clang自己的LIBC 可用性有望大大减轻该问题。手动指定正确包括dir。
还会在构建过程中分开编译和链接阶段。这将导致链接使用正确的二进制液体,而不是vs默认值。
相关文章:
- 如何从测试脚本中运行WAF编译C++程序?
- 如何使用命令提示符、记事本和 MinGW 使用主文件、头文件和实现文件编译C++程序?
- 在Yocto上本地构建和编译C / C++程序
- 我无法在代码块中编译c ++程序。它给了我错误
- 在 turbo c++ 中使用 TCC 从 cmd 编译C++程序
- 如何在Linux中编译C 程序以生成Windows可执行文件
- 在Python中编译C 程序时,请尝试捕获OS错误
- 在Windows命令提示符中使用G 编译C 程序
- 如何使用HDF5源代码编译c程序
- 如何在Mac终端中编译C ++程序
- 设置 VS 代码以编译C++程序
- 无法在 Ubuntu 上编译 c++ 程序
- 无法使用 libcurl 库编译 c++ 程序
- 编译C 程序,该程序将SFML与MINGW一起到端口,从Linux到Windows
- 编译C 程序时具有逻辑错误,该程序应将任意大的数字表示为字符串
- 如何在 Windows 命令提示符下使用 Dev C++ 编译器编译 c++ 程序
- 在cygwin中使用mingw编译器编译c ++程序时缺少dll。
- 无法在Windows上编写的Linux上编译C程序
- 架构的未定义符号x86_64惠姆使用G 编译C 程序
- 指定netbeans用来编译C++程序的完整编译命令