我本意是想在windows下学习下C++11,而结果是个人Visual Studio 2012不彻底支持,而我又懒得去安装2013/2015,太大了。公司运维也不容许我去下载- -,而后就想能不能在windows环境下搞个gcc玩,而后我又知乎了一把,大意的意见是clang把gcc甩了好远,因此我就决定安装clang环境来学习一下,过程当中仍是遇了几个坑…php
-----------------------------------------------------------------------------------------------html
下载最新的clang版本,地址:http://www.llvm.org/releases/download.html#3.7.0ios
而后编写测试用的c代码,保存为demo1.cwindows
#include <stdio.h>
int main(int argc, char *argv[]) {
printf("Hello World!");
return 0;
}
使用Win + R,切换到demo1.c的目录下,而后执行clang --verbose demo1.c会遇到错误架构
找不到stdio.h文件,以后我在网上搜索了很久,好比这一篇文章 app
http://zanedp.blogspot.com/2014/01/clang-cant-find-stdioh-etc.html运维
我按照文章提示的步骤进行安装,最后发现遇到这样的错误:学习
ld.exe: unrecognised emulation mode: i386pepSupported emulations: i386pe测试
这个问题很头疼,google出来的结果不少,却几乎没什么头绪,最后我在一个邮件列表中找到了答案google
http://comments.gmane.org/gmane.comp.lib.boost.devel/262947
缺乏stdio.h,下载mingw没有问题,问题是我使用的不是64位的!
而后我搜索关键字“mingw 64”,总算让我找到了答案,下载地址:http://mingw-w64.org/doku.php/download
注意CPU架构选择x86_64,缘由就是clang也使用的是该架构编译的
安装成功后,查看gcc的相关信息(须要把gcc安装目录的bin加入到环境变量)
若是还编译不经过(我遇到了),关闭当前的dos窗口,而后从新来一遍就能够了
main.cpp的源码:
#include <iostream>
#include <vector>
int main()
{
std::vector<int> vect {1, 2, 3, 4, 5};
for(auto& el : vect)
std::cout << " - " << el << std::endl;
return 0;}