强制gcc在64位平台上编译32位程序 [英] Force gcc to compile 32 bit programs on 64 bit platform

查看:260
本文介绍了强制gcc在64位平台上编译32位程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个专用程序,我试图在64位系统上使用。

当我启动安装程序时,它可以正常工作,但是它在尝试更新自身并编译一些模块后无法加载它们。



我怀疑它是因为它使用gcc而gcc试图为64位系统编译它们,因此这个程序不能使用这些模块。



有没有办法(一些环境变量或类似的东西)强制gcc为32位平台做所有事情。请问32位chroot的工作原理是什么?

解决方案

你需要让GCC使用 -m32 flag。



您可以尝试为 $ PATH 编写一个简单的shell脚本,并将其命名为gcc (确保你不覆盖原来的gcc,并确保新脚本早于 $ PATH ,并且它使用GCC的完整路径。



我认为你需要的代码就像 / bin / gcc -m32 $ * ,这取决于你的shell( $ * 是否包含所有参数,尽管它可能是别的东西 - 非常重要!)


I've got a proprietary program that I'm trying to use on a 64 bit system.

When I launch the setup it works ok, but after it tries to update itself and compile some modules and it fails to load them.

I'm suspecting it's because it's using gcc and gcc tries to compile them for a 64 bit system and therefore this program cannot use these modules.

Is there any way (some environmental variables or something like that) to force gcc to do everything for a 32 bit platform. Would a 32 bit chroot work?

解决方案

You need to make GCC use the -m32 flag.

You could try writing a simple shell script to your $PATH and call it gcc (make sure you don't overwrite the original gcc, and make sure the new script comes earlier in $PATH, and that it uses the full path to GCC.

I think the code you need is just something like /bin/gcc -m32 $* depending on your shell (the $* is there to include all arguments, although it might be something else – very important!)

这篇关于强制gcc在64位平台上编译32位程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆