Question

Years and years after resisting a switch to the x86_64 platform, finally I made the switch. Primarily because I wanted to play around with docker (FTW: http://docker.io).

In my line of duty I generally have to build applications for the 32 bit platform. And thus came the need to compile applications for i386 on the x86_64 host.

I am using ubuntu 13.04. I looked around a lot to figure this out before posting this question.

So here's what I gathered: 1. Need to have gcc-multilib installed (apt-get install gcc-multilib) 2. Need to have ia32-libs installed (apt-get install ia32-libs) 3. We need to specify -m32 switch to GCC

As a result, I can compile applications for i386. eg.

   $ uname -m
   x86_64
   $
   $ echo -e "#include <stdio.h>\nint main () {return 0;}" > dummy.c
   $ gcc -m32 dummy.c -o dummy
   $ file dummy
   dummy: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0xafbf2b3adc5f44a8b5c1e8bcd6de5701ff792abd, not stripped

Now here's the problem. When I try to link against the zlib library.

   $ apt-get install zlib1g-dev
   $ apt-get install zlib1g:i386 # the i386 version of zlib 
   $ gcc -m32 dummy.c -o dummy -lz
   /usr/bin/ld: cannot find -lz
   collect2: error: ld returned 1 exit status

I am not able to figure out this issue. How do I resolve it. As per my currently understanding I have installed all the required packages...

I have looked at solving this issues using a. Linux containers / docker. b. Ubuntu 13.04 i386 jailed root.

Both of the above methods work. But there are quite a few hoops to get by before getting to the point of being able to build.

But what could be better than just getting the i386 applications to compile on the x86_64 host.

Any help is greatly appreciated.

Thanks and Regards ~Sameer

Was it helpful?

Solution

You need to install the 32-bit dev packages for each library.

In this case, you should install:

sudo apt-get install zlib1g-dev:i386
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top