Compiling 32-bit GTK + applications with 64-bit Linux

I'm having trouble compiling 32-bit GTK + applications on 64-bit Linux, specifically Ubuntu 10.04. Compiling 64-bit GTK + applications works fine and everything is configured to compile 32-bit applications, but this does not work with GTK +

I have a very simple test program that I use to troubleshoot, it's just gtk_init and gtk_main, which compiles fine like -m64. I am compiling with gcc 4.6.2, calling it:

gcc -m32 gtktest.c `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0` 

These are two different types of error messages I receive:

 /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 are not the only errors, I just included two specific types for the link and so that it is short, I get errors for the whole GTK + library package.

I have all 32-bit versions of libraries in lib32 folders.

I hope that someone has come across this problem before and can help me, it really causes me headaches, and I can not help much anywhere on the network.

Please ask if there is any other information that you require me to help diagnose this problem.

Note. I have ia32-libs and gcc-multilib packages. Ubuntu 10.04 does not have separate ia32-libs-gtk packages, but I think they are wrapped in ia32-libs packages. All of them are present in my system.

I think this should be some kind of problem with the layout of the linker. I recently created a new Free Pascal compiler and a 32-bit cross-compiler, and upgraded GCC to 4.6.2 to take advantage of some of the new C ++ features and fixes to support C99. By default, 4.4.3 GCC still exists on my system. Where I think the problem was introduced when I installed the new binutils, because I experimented with Clang and LLVM as a toolchain, and I wanted ld with the capabilities of the plugin, so I decided that I could also update them all.

Everything works fine, compiling 64-bit programs, there was no problem with new tools at all, and I can compile 32-bit programs, but when it comes time to explicitly link something in my problems.

I know that my current set of libs is suitable, and I installed Free Basic, which only emits 32-bit code, and I was able to create 32-bit GTK + programs without problems before this update.

It’s just interesting if anyone has any ideas what configurations could be changed in this update, or has this happened to them before? I really have to upgrade to a newer distribution so that I can use all the new software so as not to crack all my packages, but, unfortunately, there is an error in the new kernels that prevent my computer from returning from standby mode and this is a laptop that I use for personal projects, so proper power management is very important, and this is not a huge loss if I am struggling with the system, except that I have it configured very well for my workflow.

+4
source share
3 answers

I think you need to install the ia32-libs-gtk and gcc-multilib , and you need to compile and link with gcc -m32 , as you already did.

0
source

The GTK package in 12.04 does not seem to work with multiarchy. You can get around this on Ubuntu 12.04 by creating the following symbolic links:

 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

Alternatively (perhaps better), you can leave the base system intact and update your search link by file name instead of library name. Sort of:

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

This is not great. You will need to add -l: for each library that the linker cannot find, and your assembly will be broken if the library file name ever changes.

0
source

You can specify pkg-config to search for 32-bit libraries with the PKG_CONFIG_PATH environment variable. For Ubuntu,

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

For Redhat,

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

Source: https://habr.com/ru/post/1382907/


All Articles