简体   繁体   English

编译 64 位 Linux 的 32 位 GTK+ 应用程序

[英]Compiling 32-bit GTK+ Applications of 64 bit Linux

I am having some trouble compiling 32-bit GTK+ applications on 64-bit Linux, specifically Ubuntu 10.04.我在 64 位 Linux(特别是 Ubuntu 10.04)上编译 32 位 GTK+ 应用程序时遇到了一些问题。 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+编译 64 位 GTK+ 应用程序工作正常,一切都设置为编译 32 位应用程序,但它不适用于 GTK+

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.我有一个非常简单的测试程序,用于排除故障,它只是一个 gtk_init 和一个 gtk_main,它可以很好地编译为 -m64。 I am compiling with gcc 4.6.2, calling it with:我正在使用 gcc 4.6.2 进行编译,并使用以下命令调用它:

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)

and

/usr/lib/../lib32/libgdk-x11-2.0.so: undefined reference to `XmbSetWMProperties'

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.请记住,这些不是唯一的错误,我只是包含了两个特定类型以供参考,并且为了简短起见,我收到了整个 GTK+ 库堆栈的错误。

I do have all of the proper 32-bit versions of the libraries in my lib32 folders.我的 lib32 文件夹中有所有正确的 32 位版本的库。

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.请询问您是否需要我提供任何其他信息来帮助诊断此问题。

Note: I do have the ia32-libs and gcc-multilib packages.注意:我确实有 ia32-libs 和 gcc-multilib 包。 Ubuntu 10.04 does not have a separate ia32-libs-gtk packages, but I think these are wrapped in to the ia32-libs packages. Ubuntu 10.04 没有单独的 ia32-libs-gtk 包,但我认为这些都包含在 ia32-libs 包中。 They all are present on my system.它们都存在于我的系统中。

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.我最近构建了新的 Free Pascal 编译器和 32 位交叉编译器,我还将 GCC 升级到 4.6.2 以利用一些新的 C++ 特性和对 C99 支持的修复。 The default 4.4.3 GCC still exists on my system.默认的 4.4.3 GCC 仍然存在于我的系统中。 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.我认为问题出现的地方是当我安装了一个新的 binutils 时,因为我一直在尝试使用 Clang 和 LLVM 作为工具链,并且我想要和 ld 具有插件功能,所以我认为最好将它们全部升级。

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.编译 64 位程序一切正常,新工具根本没有任何问题,我可以编译 32 位程序,但是当需要明确链接某些内容时,我遇到了问题。

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.我知道我当前的库是合适的,并且我安装了 Free Basic,它只发出 32 位代码,并且在这次升级之前我能够构建 32 位 GTK+ 程序没有问题。

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.我真的应该升级到更新的发行版,这样我就可以利用所有新软件,而不必破解我的所有软件包,但不幸的是,新内核中存在一个错误,使我的计算机无法从待机状态恢复,并且这是我用于个人项目的笔记本电脑,因此适当的电源管理非常重要,如果我破坏系统,这不会造成巨大损失,除了我为我的工作流程设置了非常完美的设置。

You may tell pkg-config to search for the 32-bit libraries with the environment variable PKG_CONFIG_PATH .您可以告诉pkg-config使用环境变量PKG_CONFIG_PATH搜索 32 位库。 For Ubuntu:对于 Ubuntu:

export PKG_CONFIG_PATH=/usr/lib32/pkgconfig:$PKG_CONFIG_PATH

For Redhat:对于红帽:

export PKG_CONFIG_PATH=/usr/lib/pkgconfig:$PKG_CONFIG_PATH

The GTK package in 12.04 doesn't seem to work correctly with multiarch. 12.04 中的 GTK 包似乎无法与 multiarch 一起正常工作。 You can work around this on Ubuntu 12.04 by creating the following symlinks:您可以通过创建以下符号链接在 Ubuntu 12.04 上解决此问题:

sudo ln -s /lib/i386-linux-gnu/libglib-2.0.so.0 /usr/lib32/libglib-2.0.so
sudo ln -s /usr/lib/i386-linux-gnu/libgtk-x11-2.0.so.0 /usr/lib32/libgtk-x11-2.0.so
sudo ln -s /usr/lib/i386-linux-gnu/libgdk-x11-2.0.so.0 /usr/lib32/libgdk-x11-2.0.so
sudo ln -s /usr/lib/i386-linux-gnu/libatk-1.0.so.0 /usr/lib32/libatk-1.0.so
sudo ln -s /usr/lib/i386-linux-gnu/libpangox-1.0.so.0 /usr/lib32/libpangox-1.0.so
sudo ln -s /usr/lib/i386-linux-gnu/libpango-1.0.so.0 /usr/lib32/libpango-1.0.so
sudo ln -s /usr/lib/i386-linux-gnu/libgmodule-2.0.so.0 /usr/lib32/libgmodule-2.0.so
sudo ln -s /usr/lib/i386-linux-gnu/libgobject-2.0.so.0 /usr/lib32/libgobject-2.0.so
sudo ln -s /usr/lib/i386-linux-gnu/libgdk_pixbuf-2.0.so.0 /usr/lib32/libgdk_pixbuf-2.0.so

I found the answer in this thread: http://www.blitzbasic.com/Community/posts.php?topic=101357我在这个线程中找到了答案: http : //www.blitzbasic.com/Community/posts.php? topic= 101357

Alternatively (probably better), you can leave the base system untouched and update your link to search by file name instead of library name.或者(可能更好),您可以保持基本系统不变并更新链接以按文件名而不是库名进行搜索。 Something like:就像是:

gcc -m32 gtktest.c `pkg-config --cflags gtk+-2.0` -L/usr/lib/i386-linux-gnu -l:libgio-2.0.so.0 ...

This isn't great.这不是很好。 You'll have to add a -l: for each library that the linker can't find and your build will break if the library file name ever changes.您必须为链接器找不到的每个库添加一个-l:并且如果库文件名发生更改,您的构建将中断。

我认为您需要安装ia32-libs-gtkgcc-multilib软件包,并且您需要像已经做的那样编译和链接gcc -m32

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM