强制 gcc 在 64 位平台上编译 32 位程序 [英] Force gcc to compile 32 bit programs on 64 bit platform
问题描述
我有一个专有程序,我想在 64 位系统上使用它.
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.
我怀疑是因为它使用 gcc 而 gcc 试图为 64 位系统编译它们,因此该程序无法使用这些模块.
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.
有什么方法(一些环境变量或类似的东西)可以强制 gcc 为 32 位平台做所有事情.32 位 chroot 可以工作吗?
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?
推荐答案
你需要让 GCC 使用 -m32
标志.
You need to make GCC use the -m32
flag.
您可以尝试为您的 $PATH
编写一个简单的 shell 脚本并将其命名为 gcc(确保您没有覆盖原始 gcc,并确保新脚本在 中更早出现$PATH
,并且它使用 GCC 的完整路径.
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.
我认为您需要的代码就像 /bin/gcc -m32 $*
之类的东西,具体取决于您的 shell($*
用于包含所有参数,虽然它可能是别的东西——非常重要!)
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屋!