Linux – Use of ia32-libs

linuxnetbeansx86

I'm trying to use the asmlibrary which I've obtained from here
I'm running in 64-bit, but the pre-compiled static library is build for 32-bit.
I don't really want to recompile the library, because I do not have OpenCV 1.0 installed, and don't really want to install such an old version of this piece of software.

My employer has told me that you may use ia32-libs which would allow me to use the library on a 64-bit machine. I have installed these libs using apt.

In netbeans, my IDE of choice, I'm now attempting to use the library. I keep getting the messages:

/usr/bin/ld: i386 architecture of input file
`../asmlib/libasmlibrary.a(asm_shape.o)' is incompatible with
i386:x86-64 output

Etc..

I have two questions:

1) Will ia32-libs allow me to use this library?

2) How must I "enable" it's use, either generally or preferably specific to netbeans (if applicable)

Thank you

Best Answer

An executable (including the libraries it depends on) has to be entirely 32 bits or 64 bits. You cannot mix and match object files of different types.

So to use a 32 bits library, you must compile your program as a 32 bits executable and link with a 32 bits version of libc and other core libraries. On debian you'll need packages like libc6-dev-i386 and ia32-libs-dev.

To compile foo.c as a 32 bits executable, use

gcc -m32 -o foo foo.c

How to do this with netbeans is left as an exercise.