premake 使用clang替换gcc

接着前文:premake在Ubuntu和GCC环境下创建简单的C++工程

由于clang支持gcc所有参数,所以使得在premake中替换gcc变得很简单。基本上就是通过传递参数或者设置环境变量的方式即可。

下面是设置环境变量的方式:

 

export CXX=clang++
export CC=clang

然后直接运行make命令,这是因为在生成的Hello1.make文件中有这么一段:

 

 

ifndef CC
  CC = gcc
endif

ifndef CXX
  CXX = g++
endif


两个环境变量设置后使得这段失效。

 

运行后报错,用config=debug verbose=1 参数发现找不到bits/c++config.h文件。查找了一下,在我的Ubuntu 13.04上位置在

 

/usr/include/x86_64-linux-gnu/c++/4.8


参考 http://industriousone.com/includedirs说明,在config.lua文件中添加:

 

 

includedirs {"/usr/include/x86_64-linux-gnu/c++/4.8"}


再次运行premake命令:

 

 

  premake4 --file=config.lua --os=linux --platform=x64 gmake


然后make,成功:

 

 

 make config=debug verbose=1 all



 

 

posted on 2013-09-03 19:36  you Richer  阅读(658)  评论(0)    收藏  举报