<摘录>如何在64位linux强制编译32位应用程序

GDC注:因为需要解决在linux64机上编译32位的mongodb(没办法,因为编译的php是32位,然后我想将mongdb扩展添加到php中),在网上搜了很多文章,感觉这篇好懂,而且好用。我使用的是方法一,具体为:

> linux32 ./configure --with-php-config=/usr/local/php/bin/php-config

> export CFLAGS="-m32 -04 -march=i386 -mtune=i386"

> make

make成功后,用file命令看一下modules目录下的生成的mongo.so。输出为“ELF 32-bit LSB shared object”。哈哈,成功!

方法一:
首先需要安装32位的兼容库

apt-get install ia32-libs libc6-dev-i386 linux32

1.用linux32命令在configure时改一下CHOST,设置一下编译环境

$ linux32 ./configure

#系统类型将变为:i686-pc-linux-gnu
#而不是x86_64-unknown-linux-gnu

2.设定GCC的参数
export CFLAGS="-m32  -march=i386 -mtune=i386"
export CFLAGS="-m32 -04 -march=i386 -mtune=i386"

#最关键是-m32

-m32, -m64
Generate code for a 32-bit or 64-bit environment. The 32-bit environment
sets int, long and pointer to 32 bits and generates code that runs on
any i386 system. The 64-bit environment sets int to 32 bits and long and
pointer to 64 bits and generates code for
AMD‘s x86-64 architecture.

方法二:

修改/usr/bin/gcc ld,强制加入m32信息

将gcc,ld重命名为gcc.64,ld.64

/usr/bin/gcc

#!/bin/sh

gcc.64 –m32 [email protected]

/usr/bin/ld

#!/bin/sh

ld.64 –m elf_i386 [email protected]

时间: 2024-08-04 22:19:53

<摘录>如何在64位linux强制编译32位应用程序的相关文章

在64位linux上编译32位程序

ld指令有一个选项:--oformat output_format,用于指定输出文件的格式.输入文件./kernel/kernel.o等是elf32格式,当前系统是64位,而ld默认生成的文件格式是elf64-x86-64:因此会出现"ld: warning: i386 architecture of input file `./kernel/kernel.o' is incompatible with i386:x86-64 output"这样的提示.之前,将系统从三墩转移到我自己的

在64位linux上编译32位程序 for i386 intel

编辑中 # ld -V GNU ld version 2.15.92.0.2 20040927 Supported emulations: elf_x86_64 elf_i386 i386linux #ld -m elf_i386 Along with the -m32 flag in gcc, you may need to include the -melf_i386 flag for ld to properly link the 32bit object files to the 32b

在64位linux下安装32位oracle软件

在某些情况下,有时我们需要在64位的系统下来安装32的oracle软件(如,客户的变态要求).虽然在理论上,这种方式是可行的,但在实际的安装过程中确往往是错误百出,为了避免不必要的错误,也为了方便以后的工作查找,记录安装过程. 本示例以redhat4--64位操作系统,oracle 10g为数据库,安装过程中,仅仅使用了最小的安装包,以便尽可能多的发现问题.由于问题主要出现在软件包的安装和兼容性上,安装过程的其他方面不过多涉及. 首先,配置yum使用本地光盘作为源,并配置同时安装32位和64位的

64位linux yum安装32位的rpm包

在64位的Linux安装64位的oracle的时候,有时候会出现"libXext.so.6: cannot open shared object file:"的错误. 或者有时出现 libXp.so.6 is needed by openmotif21-2.1.30-11.EL...错误. 这个原因主要是oracle在安装的时候需要安装一些32位的lib,可以采用如下的解决办法: # yum list  available  | grep  libXp libXp.i686     

在64位Linux上安装32位gmp大数库

前期准备: 如果没有安装32位gcc和g++环境的话,可能会导致安装失败,此时请参考上一篇博文 http://www.cnblogs.com/weir007/p/5977759.html,根据系统版本配置编译环境. 下载gmp源码(如gmp-6.1.0.tar.bz2),解压,cd进入gmp解压后文件夹: 依次运行指令: ABI=32 CFLAGS=-m32 ./configure make check 2>&1 | tee gmp-check-log (由于平台问题,需要仔细检测,确保所有

hadoop2.5发布:最新编译 32位、64位安装、源码包、API以及新特性

hadoop2.5发布:最新编译 32位.64位安装.源码包.API以及新特性 http://www.aboutyun.com/thread-8751-1-1.html (出处: about云开发) 问题导读:1.如何获取Hadoop安装包?2.编译Hadoop过程中,需要注意哪些问题?3.如何寻找API?4.如何获取Hadoop源码? 上述问题有的在本文,有的则在本文链接,感兴趣,可以找找答案 2014年08月06日 Hadoop2.5发布 官网下载地址 对Hadoop2.5进行了编译,编译的

64位SUSE编译32位程序出错

These `-m' switches are supported in addition to the above on AMD x86-64 processors in 64-bit environments. -m32 -m64 -mx32 Generate code for a 32-bit or 64-bit environment. The -m32 option sets int, long and pointer to 32 bits and generates code tha

hadoop2.6.0汇总:新增功能最新编译 32位、64位安装、源码包、API下载及部署文档

相关内容: hadoop2.5.2汇总:新增功能最新编译 32位.64位安装.源码包.API.eclipse插件下载Hadoop2.5 Eclipse插件制作.连接集群视频.及hadoop-eclipse-plugin-2.5.0插件下载hadoop2.5.1汇总:最新编译 32位.64位安装.源码包.API下载及新特性等 新手指导:hadoop官网介绍及如何下载hadoop(2.4)各个版本与查看hadoop API介绍 从零教你在Linux环境下(ubuntu 12.04)如何编译hadoo

如何查看linux系统是32位还是64位

1.#uname -a 如果有x86_64就是64位的,没有就是32位的 # uname -a  Linux desktop 2.6.35-23-generic #37-Ubuntu SMP Fri Nov 5 19:17:11 UTC 2010 i686 GNU/Linux 这是32位的  #uname -a  Linux backup 2.6.9-67.ELsmp #1 SMP Wed Nov 7 13:58:04 EST 2007 i686 i686 i386 GNU/Linux  注意: