premake在Ubuntu和GCC环境下创建简单的C++工程
由于premake基于lua脚本,为了方便编辑lua脚本,我在emacs24中利用package system安装了lua-mode。
然后创建config.lua文件,填入下面这段,主要来自:http://industriousone.com/basic-script
-- A solution contains projects, and defines the available configurations
solution "Hello1"
configurations { "Debug", "Release" } -- A project defines one build target
project "Hello1"
kind "ConsoleApp"
language "C++"
files { "**.h", "**.cpp" } configuration "Debug"
defines { "DEBUG" }
flags { "Symbols" } configuration "Release"
defines { "NDEBUG" }
flags { "Optimize" }
创建main.cpp文件,很简单:
#include <iostream>
using namespace std; int main(void) {
cout << "hello1" << endl;
}
运行premake命令产生makefile
premake_study/hello1$ premake4 --file=config.lua --os=linux --platform=x64 gmake
Building configurations...
Running action 'gmake'...
Generating Makefile...
Generating Hello1.make...
Done.
现在执行make命令:
make
==== Building Hello1 (debug) ====
Creating obj/Debug
main.cpp
Linking Hello1
创建了一个obj/Debug目录树,
premake_study/hello1$ tree
.
├── config.lua
├── Hello1
├── Hello1.make
├── main.cpp
├── Makefile
└── obj
└── Debug
├── main.d
└── main.o
运行Hello1, 成功打印"hello1" 字符串。
看一下产生的Makefile文件内容,会知道如何使用。
# GNU Make solution makefile autogenerated by Premake
# Type "make help" for usage help ifndef config
config=debug
endif
export config PROJECTS := Hello1 .PHONY: all clean help $(PROJECTS) all: $(PROJECTS) Hello1:
@echo "==== Building Hello1 ($(config)) ===="
@${MAKE} --no-print-directory -C . -f Hello1.make clean:
@${MAKE} --no-print-directory -C . -f Hello1.make clean help:
@echo "Usage: make [config=name] [target]"
@echo ""
@echo "CONFIGURATIONS:"
@echo " debug"
@echo " release"
@echo " debug64"
@echo " release64"
@echo ""
@echo "TARGETS:"
@echo " all (default)"
@echo " clean"
@echo " Hello1"
@echo ""
@echo "For more information, see http://industriousone.com/premake/quick-start"
好了,默认是Debug版本,现在运行命令,可以创建release版本。
premake_study/hello1$ make config=release all
==== Building Hello1 (release) ====
Creating obj/Release
main.cpp
Linking Hello1
还可传递参数 config=release64和config=debug64. 咋一看比cmake贴心好用。
不过以为之前运行premake4命令传递参数是--platform=x64, 所以这里make传递的config不管是什么都编译出64bit bianry. 用file命令可以查看之:
file Hello1
Hello1: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0xdef2bc128f21a691fa196dc20c50b7ad4dc56d0f, stripped
premake可以用来清理产生的make file
premake_study/hello1$ premake4 --file=config.lua clean
Building configurations...
Running action 'clean'...
Done.
不过即便我这里premake4用了参数--platform=x32,编译出来的还是64bit的binary。
还不是很清楚原因。
如果想要详细的看到编译的执行过程,和CMake使用方式一样,在make的时候加参数verbose=1
premake_study/hello1$ make config=release verbose=1 all
==== Building Hello1 (release) ====
Creating obj/Release
mkdir -p obj/Release
main.cpp
g++ -MMD -MP -DNDEBUG -O2 -o "obj/Release/main.o" -MF obj/Release/main.d -c "main.cpp"
Linking Hello1
g++ -o ./Hello1 obj/Release/main.o -s
premake在Ubuntu和GCC环境下创建简单的C++工程的更多相关文章
- ubuntu 14.04LTS 环境下配置NFS服务
简言之,NFS(Network FileSystem,网络文件系统)用于在不同机器,不同操作系统之间通过网络互相分享各自的文件.NFS设计之初就是为了在不同的系统间使用,所以它的通讯协议设计与主机及操 ...
- ubuntu 14.04LTS 环境下搭建tftp服务器
花费我一整天的时间在 ubuntu 14.04LTS 环境下搭建tftp服务器,网上好多资料参差不齐,简单来说,TFTP(Trivial File Transfer Protocol),是一个基于UD ...
- windows环境下创建 .文件夹
一.windows环境下创建 .文件夹 1.新建一个文件夹 2.重命名为.properties.(名字前后都加点) 二.windows环境下创建 .文件 1.上面的方法对文件同样适用 2.运行CMD, ...
- Ubuntu 12.04环境下配置Postgresql和phppgadmin
Ubuntu 12.04环境下配置Postgresql 9.1 和phppgadmin 本系列文章由ex_net(张建波)编写,转载请注明出处. http://blog.csdn.net/zjianb ...
- ROS 教程之 navigation :在 catkin 环境下创建costmap layer plugin
在做机器人导航的时候,肯定见到过global_costmap和local_costmap.global_costmap是为了全局路径规划服务的,如从这个房间到那个房间该怎么走.local_costma ...
- centos环境下创建数据库和表的方法
centos环境下创建数据库和表的方法 //查询数据库的命令: mysql> SHOW DATABASES; +--------------------+ | Database ...
- 【转】用systemJS+karma+Jasmine+babel环境去编写简单的ES6工程
原文链接:http://www.cnblogs.com/shuoer/p/7779131.html 用systemJS+karma+Jasmine+babel环境去编写简单的ES6工程 首先解释下什么 ...
- Ubuntu 16.04 环境下配置apache2.4 + php5.6
相信用惯了Windows的朋友一开始接触Linux是很崩溃的,因为很多东西都是通过命令行来完成的,包括安装绝大多数的开发工具以及环境,那么在Ubuntu下其实可以直接通过apt-get指令来安装apa ...
- 在Windows中单机环境下创建RabbitMQ集群
本文根据:http://www.360doc.com/content/15/0312/17/20874412_454622619.shtml整理而来 RabbitMQ具有很好的消息传递性能,同时又是开 ...
随机推荐
- (Problem 33)Digit canceling fractions
The fraction 49/98 is a curious fraction, as an inexperienced mathematician in attempting to simplif ...
- sorl6.0+jetty+mysql
sorl6.0+jetty+mysql搭建solr服务 1.下载solr 官网:http://lucene.apache.org/solr/ v2.目录结构如下 v3.启动solr(默认使用jetty ...
- cocos2d-x游戏开发系列教程-超级玛丽09-怪物激活与移动
在游戏中,很多怪物本身是会移动的,这里主要有蘑菇怪,乌龟等. 说起怪物的移动,首先在游戏里先要考虑怪物的抽象和设计. 在CMMonster.h中,有个类CMMonsterBasic,这个类抽象了所有的 ...
- Objective中的协议(Protocol)
Objective中的协议(Protocol) 作用: 专门用来声明一大堆方法. (不能声明属性,也不能实现方法,只能用来写方法的声明). 只要某个类遵守了这个协议.就相当于拥有这个协议中的所有的方法 ...
- 【jQuery】使用JQ来编写面板的淡入淡出效果
本文与上一篇的<[jQuery]使用JQ来编写最主要的淡入淡出效果>(点击打开链接)为姊妹篇. 但上一篇仅仅是对文本的基本控制,本篇则是对面板元素进行控制. 尽管功能上很类似,可是所用到的 ...
- TCP之超时和重传
RTT:往返时间: RTO:Retransmission Timeout即超时重传时间: 关键点在于:超时和重传间隔的策略,即怎样确定超时间隔和重传间隔: TCP中的四个定时器:2MSL定时器:重传 ...
- 以路由控制URL
至此为止,我们一直在使用ASP.NET MVC新项目随带的默认路由配置.现在我们将深入探讨路由系统,并学习如何创建应用程序的自定义路由,以确保URL既是用户友好又是搜索引擎可访问的. 路由的全部内容都 ...
- northern truck 是什么牌子?具体_百度知道
northern truck 是什么牌子?具体_百度知道 northern truck 是什么牌子?具体
- css3处理sprite背景图压缩来解决H5网页在手机浏览器下图标模糊的问题
近期在负责一个微信H5 App项目,遇到一个郁闷的问题,手机浏览器查看网页时图标都是模糊的,有锯齿,电脑浏览器显示则是正常.大概知道是分辨率适配等类型的问题,后来网上查找了一些办法.大部分的解决方式都 ...
- QTP的基本功能介绍
• QTP的基本功能介绍 HP QuickTest Professional 支持功能測试和回归測试自己主动化,用于每一个主要软件应用程序和环境.此解决方式使用keyword驱动的測试概念,简化了測试 ...