如何用64bit gcc編譯32bit程式[HowTo Compile a 32-bit Application Using gcc On the 64-bit Linux Version](GOOGLE: LINUX GCC 32 64)

如何用64bit gcc編譯32bit程式[HowTo Compile a 32-bit Application Using gcc On the 64-bit Linux Version](GOOGLE: LINUX GCC 32 64)

如何用64bit gcc編譯32bit程式[HowTo Compile a 32-bit Application Using gcc On the 64-bit Linux Version](GOOGLE: LINUX GCC 32 64)


資料來源: https://koukaipan.pixnet.net/blog/post/23195769

https://www.cyberciti.biz/tips/compile-32bit-application-using-gcc-64-bit-linux.html


You can pass -m64 or -m32 options as follows to Gnu gcc

01.For 32 bit version:

$ gcc -m32 -o output32 hello.c

02.For 64 bit version :

$ gcc -m64 -o output64 hello.c

03.Run it as follows:

$ ./output32

Output:

Long int size is 4 bytes long!

04.Now let us see 64 bit output:

$ ./output64

Output:

Long int size is 8 bytes long!

05.Sample code – hello.c

#include <stdio.h>
int main()
{
        long z; printf("Long int size is %i bytes long!\n", sizeof(z)); return 0;
}

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *