首先,要安装GCC 4.8, 参考前文:Ubuntu 12.04 & 13.04 安装 GCC4.8.1

其中,重点是安装multilib

apt-get install gcc-4.8-multilib  

接着前文premake管理一个solution和多个project的目录树做一些修改:

1.创建四个configuration,分别为Debu64, Release64, Debug32和Release32, 把它们放在solution下面,这样,每个proejct都共享这些设置。

-- A solution contains projects, and defines the available configurations
solution ("solution2")
configurations {"Debug64", "Release64", "Debug32", "Release32"}
location "build"
targetdir "output" configuration "Debug64"
defines { "DEBUG" }
flags { "Symbols" } configuration "Release64"
defines { "NDEBUG" }
flags { "Optimize" } configuration "Debug32"
linkoptions {"-m32"}
defines { "DEBUG -m32" }
flags { "Symbols" } configuration "Release32"
linkoptions {"-m32"}
defines { "NDEBUG, -m32" }
flags { "Optimize" }

2. 注意上面的32位的配置,添加了linkoptions,并且在defines里面添加了-m32, 这里很别扭。因为-m 在gcc中叫做machine options参数,而premake中没有对应的,只能用defines函数添加。下面这个方式很不好,虽然work.

defines {"DEBUG -m32"}

3. 编译并检查

然后开始运行命令:

/solution2$ premake4 --file=config.lua gmake
Building configurations...
Running action 'gmake'...
Generating build/Makefile...
Generating build/hello1/Makefile...
Generating build/hello2/Makefile...
Done.

进入build目录,开始编译

 cd build/
CHN\shu6889@sloop2:~/work/gitlab/raster/codes/study/premake/solution2/build$ make config=debug32
==== Building hello1 (debug32) ====
Creating ../../output
Creating obj/Debug32
main.cpp
Linking hello1
==== Building hello2 (debug32) ====
Creating obj/Debug32
main.cpp
Linking hello2

现在检查output目录中的两个binary,看看是不是32位。

solution2/build$ cd ../output/
CHN\shu6889@sloop2:~/work/gitlab/raster/codes/study/premake/solution2/output$ file hello1
hello1: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0x21747ca29b73061ed5ff3d122c8b2318941bce5d, not stripped
CHN\shu6889@sloop2:~/work/gitlab/raster/codes/study/premake/solution2/output$ file hello2
hello2: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0x975e62f065dc80f22aaa22da30b4f65d4a8b2db8, not stripped

编译成功。

4. 现在用clang试一下,添加环境变量:

export CXX=clang++
export CC=clang

重复第3步,成功。

premake 在64位Ubuntu系统下编译32位GCC程序的更多相关文章

  1. 在64位Ubuntu系统上安装32位程序包

    在64位Ubuntu系统上安装32位的程序包 $sudo apt-get install package_name:i386 例如: $sudo apt-get install openjdk-7-j ...

  2. 64位Ubuntu系统下ROP攻击

    64位Ubuntu系统下ROP攻击 基础知识 ROP攻击 ROP全称为Retrun-oriented Programmming(面向返回的编程)是一种新型的基于代码复用技术的攻击,攻击者从已有的库或可 ...

  3. 64位系统下注册32位dll文件

    64位系统下注册32位dll文件 在64位系统里注册32位软件所需的一些dll会提示不兼容,大概因为32 位进程不能加载64位Dll,64位进程也不可以加载32的导致. 若要支持的32 位和64 位C ...

  4. 64位系统下注册32位dll、ax文件

    64位系统下注册32位dll.ax文件. 换了64位系统遇到的新问题,目前常用的影音处理软件多数为32位. 注册这些32的滤镜会提示不兼容,大概因为32 位进程不能加载64位Dll,64位进程也不可以 ...

  5. 在64位linux下编译32位程序

    在64位linux下编译32位程序 http://blog.csdn.net/xsckernel/article/details/38045783

  6. win10 64位专业版系统中显示32位dcom组件配置的方法

    word.excel是32位的组件,当用户64位系统在运行窗口中输入dcomcnfg命令时,在打开的组件服务管理窗口,是找不到Microsoft Excel.word程序的.另外,Windows 环境 ...

  7. WinDbg 在64位系统下转储32位进程

    在64位系统下,首先要判断进程是32位,还是64位 在Win8之前,进程名后带星号(*)则是32位进程.但Win8.1后,则不显示星号.需要选出“平台”列,来确认32位,还是64位. 在64位系统下的 ...

  8. pyinstaller在64位系统下打包32位程序

    使用环境说明:win10 64位,已安装python3.6-64位版本 遇到的问题:win10 64位打包成exe文件后,不能在32位系统运行 需求:使用python打包生成exe文件,win64位和 ...

  9. 64位操作系统下调用32位com的问题

    Hello Guys! I am trying to create a simple VBS script to automatically open some .tif images from a ...

随机推荐

  1. 在开发 ExtJS 应用程序常犯的 10 个错误

    这是 CNX 公司在开发 ExtJS 项目中总结的需要特别注意的 10 个地方.有时候,我们完全是自己使用 ExtJS 从零开始构建的新的应用程序,但有时候我们的客户会要求我们使用他们自己的代码,并且 ...

  2. UVA 10581 - Partitioning for fun and profit(数论递推)

    10581 - Partitioning for fun and profit 题目链接 题意:给定m, n,表示分配给n个格子,分配m个数字进去,每一个格子最少1,而且序列要是递增的,问第k个字典序 ...

  3. C++中实现 time_t, tm 相互转换

    time_t -> tm: localtime tm -> time_t: mktime time_t curTime; time(&curTime); dwCurTime = c ...

  4. C++-struct类的新特性当class用

    #include <iostream> #include <iomanip> #include <string> using namespace std; stru ...

  5. C++智能指针的实现

    说起智能指针,不少人都不陌生.比方auto_ptr.shared_ptr.unique_ptr.weak_ptr. 依据shared_ptr的功能,自己仿造也实现了个. 对于shared_ptr这样的 ...

  6. oncreate 测量尺寸

    在android中,在oncreate里面只是将布局信息设置好,并没有进行布局,因此是没法进行测量view或者屏幕的长高,可以通过下面的observer来观察,当view布局完成之后会回调下面的两个接 ...

  7. 开源数据库连接池之Tomcat内置连接池

    本篇介绍几种开源数据库连接池,同时重点讲述如何使用Tomcat服务器内置的数据库连接池. 之前的博客已经重点讲述了使用数据库连接池的好处,即是将多次创建连接转变为一次创建而使用长连接模式.这样能减少数 ...

  8. asp.net下利用MVC模式实现Extjs表格增删改查

    在网上看到有很多人写extjs下的表格控件的增删改查,但是大多数都是直接从后台读取数据,很少有跟数据库进行交互的模式. 今天就来写一个这样的例子.欢迎大家交流指正. 首先简单介绍一下MVC模式,MVC ...

  9. post 请求参数

    perl代码: my $login_url='http://192.168.1.1/getpage.gch?pid=1001&logout=1'; my $res = $ua->post ...

  10. Effective C++_笔记_条款05_了解C++默认编写并调用哪些函数

    (整理自Effctive C++,转载请注明.整理者:华科小涛@http://www.cnblogs.com/hust-ghtao/) 直接上代码: 1: class Empty{}; 如果你写了这样 ...