< excerpt > How to force 32-bit applications to be compiled on 64-bit Linux

Source: Internet
Author: User

GDC Note: Because the need to solve the linux64 machine compiled 32 bits of MongoDB (no way, because the compiled PHP is 32 bits, and then I want to add mongdb extension to php), searched the Internet a lot of articles, feel this article understood, and useful. I'm using method one, specifically:

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

> Export cflags= "-m32-04-march=i386-mtune=i386"

> Make

After make succeeds, use the file command to look at the generated mongo.so in the modules directory. The output is "ELF 32-bit LSB Shared Object". Haha, success!


Method One:
First you need to install32-Bit compatibility libraries

Apt-get Install ia32-libs libc6-dev-i386 linux32

1.Uselinux32Command inConfigureWhen you change it.Chost, set up the compilation environment

$ linux32./configure

#i686-pc-linux-gnu
#x86_64-unknown-linux-gnu

2. set gcc
Export cflags= "-m32  -march=i386-mtune=i386"
Export cflags= "-m32-04-march=i386-mtune=i386"

# most critical is -m32

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

Method Two:

Modify/USR/BIN/GCC LD, force join M32 Information

Rename Gcc,ld to 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]

< excerpt > How to force 32-bit applications to be compiled on 64-bit Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.