[英]What is difference between 32-bit gcc and 64-bit gcc with -m32 option?
My team have been working on JNI recently so we faced different issues regarding 32-bit and 64-bit architectures. 我的团队最近一直在研究JNI,因此我们遇到了有关32位和64位架构的不同问题。 Let's take an example (
temp.c
). 我们来举个例子(
temp.c
)。
#include <stdio.h>
void main(){
printf("long=%d\n",sizeof(long));
}
Is there any difference between gcc_32_bit temp.c
and gcc_64_bit -m32 temp.c
? gcc_32_bit temp.c
和gcc_64_bit -m32 temp.c
之间有什么区别吗?
Cases tested: 案例测试:
Case-1: code compiled on 64-bit ubuntu using gcc temp.c
. 案例1:使用
gcc temp.c
在64位ubuntu上编译的代码。 Output: long=8
on 64-bit ubuntu. 输出: 64位ubuntu上的
long=8
。
Case-2: code compiled on 64-bit ubuntu using gcc -m32 temp.c
. 案例2:使用
gcc -m32 temp.c
在64位ubuntu上编译的代码。 Output: long=4
on 64-bit ubuntu. 输出: 64位ubuntu上的
long=4
。
Case-3: code compiled on 64-bit MAC ( 64-bit cross compiler used ) using /usr/local/gcc-4.8.1-for-linux64/bin/x86_64-pc-linux-gcc temp.c
. 情况3:使用
/usr/local/gcc-4.8.1-for-linux64/bin/x86_64-pc-linux-gcc temp.c
在64位MAC(使用的64位交叉编译器 )上编译的代码。 Output: long=8
on 64-bit ubuntu. 输出: 64位ubuntu上的
long=8
。
Case-4: code compiled on 64-bit MAC ( 32-bit cross compiler used ) using /usr/local/gcc-4.8.1-for-linux32/bin/i586-pc-linux-gcc temp.c
. 案例4:使用
/usr/local/gcc-4.8.1-for-linux32/bin/i586-pc-linux-gcc temp.c
在64位MAC(使用的32位交叉编译器 )上编译的代码。 Output: Error: cannot run
on 64-bit ubuntu. 输出:
Error: cannot run
在64位ubuntu上Error: cannot run
。
We are using MAC cross compiler because we do not have 32-bit linux machine. 我们使用MAC交叉编译器,因为我们没有32位linux机器。
It could seem a little weird, but it has started working out of nowhere. 这看起来有点奇怪,但它已经开始无处可寻。
As amdn posted in comments above, it could be due to some missing library for 32-bit. 正如amdn在上面的评论中发布的那样,可能是由于某些32位库丢失了。 Since it was not working earlier, I installed gcc-multilib and some auto updates of Ubuntu and it has started working.
由于它没有提前工作,我安装了gcc-multilib和Ubuntu的一些自动更新,它已经开始工作了。
Thank you everyone for your great help. 谢谢大家的帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.