编译 64 位 Linux 的 32 位 GTK+ 应用程序 [英] Compiling 32-bit GTK+ Applications of 64 bit Linux
问题描述
我在 64 位 Linux(特别是 Ubuntu 10.04)上编译 32 位 GTK+ 应用程序时遇到了一些问题.编译 64 位 GTK+ 应用程序工作正常,一切都设置为也编译 32 位应用程序,但它不适用于 GTK+
I am having some trouble compiling 32-bit GTK+ applications on 64-bit Linux, specifically Ubuntu 10.04. Compiling 64-bit GTK+ applications works fine, and everything is set up to compile 32-bit apps as well, but it doesn't work with GTK+
我有一个非常简单的测试程序,用于排除故障,它只是一个 gtk_init 和一个 gtk_main,编译为 -m64.我正在用 gcc 4.6.2 编译,调用它:
I have a very simple test program that I am using for trouble shooting that is simply a gtk_init and a gtk_main, which compiles fine as -m64. I am compiling with gcc 4.6.2, calling it with:
gcc -m32 gtktest.c `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0`
这是我收到的两种不同类型的错误消息:
These are the two different kinds of error messages I get:
/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/../../../../x86_64-unknown-linux-gnu/bin/ld: warning: libXext.so.6, needed by /usr/lib/../lib32/libgtk-x11-2.0.so, not found (try using -rpath or -rpath-link)
和
/usr/lib/../lib32/libgdk-x11-2.0.so: undefined reference to `XmbSetWMProperties'
请记住,这些不是唯一的错误,我只是包含了两个特定类型以供参考,并且为了简短起见,我收到了整个 GTK+ 库堆栈的错误.
Keep in mind that these aren't the only errors, I just included the two specific types for reference and to keep it short, I get errors for the whole stack of GTK+ libraries.
我的 lib32 文件夹中有所有正确的 32 位版本的库.
I do have all of the proper 32-bit versions of the libraries in my lib32 folders.
希望之前有人遇到过这个问题并且可以帮助我,这真的让我很头疼,而且我在网上的任何地方都帮不上忙.
Hopefull someone has had this problem before and can help me, this is really causing me quite the headaches, and I can't fine much help any where on the net.
请询问您是否需要我提供任何其他信息来帮助诊断此问题.
Please ask if there is any other information you need me to provide to help with diagnosing this problem.
注意:我确实有 ia32-libs 和 gcc-multilib 包.Ubuntu 10.04 没有单独的 ia32-libs-gtk 包,但我认为这些都包含在 ia32-libs 包中.它们都存在于我的系统中.
Note: I do have the ia32-libs and gcc-multilib packages. Ubuntu 10.04 does not have a separate ia32-libs-gtk packages, but I think these are wrapped in to the ia32-libs packages. They all are present on my system.
我认为这一定是某种链接器配置问题.我最近构建了新的 Free Pascal 编译器和 32 位交叉编译器,我还将 GCC 升级到 4.6.2 以利用一些新的 C++ 特性和对 C99 支持的修复.默认的 4.4.3 GCC 仍然存在于我的系统中.我认为问题出现的地方是当我安装了一个新的 binutils 时,因为我一直在尝试使用 Clang 和 LLVM 作为工具链,并且我想要和 ld 具有插件功能,所以我认为最好将它们全部升级.
I think this must be some sort of linker config problem. I've recently built the new Free Pascal compiler and a 32 bit cross compiler, and I also upgraded GCC to 4.6.2 to take advantage of some of the new C++ features and fixes to C99 support. The default 4.4.3 GCC still exists on my system. Where I think the problem has been introduced is when I installed a new binutils because I've been experimenting with Clang and LLVM as a toolchain, and I wanted and ld with plug-in capabilities, so I figured might as well upgrade them all.
编译 64 位程序时一切正常,新工具完全没有问题,我可以编译 32 位程序,但是当需要显式链接某些内容时,我遇到了问题.
Everything works fine compiling 64 bit programs, there hasn't been a single problem with the new tools at all, and I can compile 32-bit programs but when it comes time to explicitly link something in I have problems.
我知道我当前的库是合适的,并且我安装了 Free Basic,它只发出 32 位代码,并且在这次升级之前我能够构建 32 位 GTK+ 程序没有问题.
I know my current set of libs is appropriate, and I have Free Basic installed which only emits 32 bit code, and I was able to build 32-bit GTK+ programs no problem before this upgrade.
只是想知道是否有人知道这次升级中可能更改了哪些配置,或者他们以前发生过这种情况?我真的应该升级到更新的发行版,这样我就可以利用所有新软件,而不必破解我的所有软件包,但不幸的是,新内核中存在一个错误,使我的计算机无法从待机状态恢复,并且这是一台我用于个人业余项目的笔记本电脑,因此适当的电源管理非常重要,如果我把系统弄坏了,这并不是一个巨大的损失,除了我将它设置得非常适合我的工作流程.
Just wondering if anyone has any ideas what configs might have been changed in this upgrade or has had this happen to them before? I really should upgrade to a newer distro so I can take advantage of all the new software with out have to hack up all of my packages, but unfortunatly there is a bug in the newer kernels that prevents my computer from coming back from standby, and this is a laptop I use for personal side projects, so proper power management is pretty important, and it's not a huge loss if I bork the system, other than I have it set up pretty much perfect for my workflow.
推荐答案
您可以告诉 pkg-config
使用环境变量 PKG_CONFIG_PATH
搜索 32 位库.对于 Ubuntu:
You may tell pkg-config
to search for the 32-bit libraries with the environment variable PKG_CONFIG_PATH
.
For Ubuntu:
export PKG_CONFIG_PATH=/usr/lib32/pkgconfig:$PKG_CONFIG_PATH
对于红帽:
export PKG_CONFIG_PATH=/usr/lib/pkgconfig:$PKG_CONFIG_PATH
这篇关于编译 64 位 Linux 的 32 位 GTK+ 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!