Summary of compiler commands under Linux and AIX

Source: Internet
Author: User

64-bit Linux compiler 32-bit program command: Gcc-m32 test.c-o test32

64-bit Linux compiler 64-bit program command: gcc-m64 test.c-o Test64


64-bit Linux compiles 32-bit. O Command: gcc-m32-c test.c

64-bit Linux compiles 64-bit. O Command: gcc-m64-c test.c


64-bit Linux compiled 32-bit Static library command: AR cr libt32.a SOTEST.O

64-bit Linux compiled 64-bit Static library command: AR cr libt64.a SOTEST.O


64-bit Linux compiled 32-bit Dynamic library command: gcc-m32-g-wall-shared-fpic sotest.c-o libt32.so

64-bit Linux compiled 64-bit Dynamic library command: gcc-m64-g-wall-shared-fpic sotest.c-o libt64.so


64-bit Linux compile 32-bit invoke Dynamic Library program command: Gcc-m32 test.c-l./-lt32-o t32 or gcc-m32 test.c libt32.so-o T32 the same effect

64-bit Linux compile 64-bit invoke Dynamic Library program command: gcc-m64 test.c-l./-lt64-o t64 or gcc-m64 test.c libt64.so-o T64 the same effect


To view the static library export function: Nm-s *.a

View. A library file number of bits: Objdump-a *.a

View. So library file bits: objdump-a *.so or file *.so

--------------------------------------------------------------------------------------------------------------- --------

64-bit AIX compiled under 32-bit program command: gcc-maix32 test.c-o test32

64-bit AIX compiled under 64-bit program command: gcc-maix64 test.c-o Test64


64-bit Linux compiles 32-bit. O Command: gcc-m32-c test.c

64-bit Linux compiles 64-bit. O Command: gcc-m64-c test.c


64-bit AIX compiles 32-bit static library commands ar cr libt32.a *.O

64-bit AIX compiles 64-bit static library commands ar-x64 CR libt64.a *.O


32-bit Dynamic Library command compiled under 64-bit AIX: gcc-maix32-g-wall-shared-fpic Sotest.c-o libt32.so

64-bit Dynamic Library command compiled under 64-bit AIX: gcc-maix64-g-wall-shared-fpic Sotest.c-o libt64.so


64-bit AIX compiles 32-bit calls to the Dynamic Library Program command: gcc-maix32 test.c libt32.so-o T32

64-bit AIX compiles 64-bit calls to the Dynamic Library Program command: gcc-maix64 test.c libt64.so-o T64


View 32-bit static library export functions: NM *.A

View 64-bit static library export functions: nm-x64 *.A

View. So library files: file *.so

--------------------------------------------------------------------------------------------------------------- --------

64-bit Linux compile 32 program error message:/usr/include/gnu/stubs.h:7:27:error:gnu/stubs-32.h:no such file or directory

# yum-y Install glibc-devel.i386


1, 64 for Linux compilation if the program is compiled without the m64 parameter is still 64 bits

2, the compilation Directory execution export ld_library_path=./: $LD _library_path, can not find the current directory so library problems

3, 64-bit program in the header file definition plus #pragma pack (4) to indicate that the structure is aligned in four bytes, or there may be an int type of struct int type and close to a type interval 8 bytes of the case

When explicitly called, do not add "-L Library name" in Makefile, direct dlopen and then get function address call.
Implicit linking requires the inclusion of a header file plus "-L library name", which can be called directly.
Static links need to include the header file Plus "-L library name", the library should be. A library.

This article from the "Clear" blog, reproduced please contact the author!

Summary of compiler commands under Linux and AIX

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.