64-bit compilation of 32-bit applications

Source: Internet
Author: User
64-bit compiled 32-bit applications-general Linux technology-Linux programming and kernel information. The following is a detailed description. Inform the gcc compiler that the compiling platform is i386, and the-m32 parameter must be added to CFLAGS.

2) use the linux32 command to change CHOST in configure and set the compiling environment.

Differences before and after using the linux32 command

Staff-1 :~ /Src/lame-3.96.1 #./configure
Checking build system type... X86_64-unknown-linux-gnu
Checking host system type... X86_64-unknown-linux-gnu

Staff-1 :~ /Src/lame-3.96.1 # linux32./configure
Checking build system type... I686-pc-linux-gnu
Checking host system type... I686-pc-linux-gnu

3) if the compiled program is 32-bit, the required dynamic link library also needs to be re-compiled, for example, mplayer needs to use mp3lame, jpeg-6b, libpng, etc., all need to re-compile.

4) How do I know whether an application is 64-bit or 32-bit? You can use the file command to view details.

Staff-1 :~ # File/bin/ls
/Bin/ls: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.6.0, dynamically linked (uses shared libs ), for GNU/Linux 2.6.0, stripped

Staff-1 :~ # File/usr/bin/mplayer
/Usr/bin/mplayer: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.0, dynamically linked (uses shared libs ), for GNU/Linux 2.6.0, stripped

5) Some examples prepared before compilation, mplayer

Linux32./configure -- prefix =/usr -- cc = "gcc-m32" -- target = "i386-linux"
Make
Make install

Note:-cc ,? The target parameter is not necessarily provided by every configure program and must be flexible. In essence, some environment variables are set and can be configured manually.

Export CFLAGS = "-m32-04-march = i386-mtune = i386"

6) Be aware of conflicts with the original shared library. Try not to compile it to the/usr directory. Otherwise, the normal operation of other 64-bit programs will fail.
Related Article

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.