2

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

2 Answers2

5

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.

1

I don't think that you are able to use ia32-libs to compile a 64-bit program, using 32-bit libraries. That isn't what ia32-libs is designed for...it's designed to run entirely 32-bit programs on 64-bit systems.

I think your best bet would be to compile as 32-bit software. If you were using the command line, you can just add the -m32 flag to gcc. With netbeans, in Project Properties > Build > C Compiler (or C++ compiler if that's what you are using), there is a dropdown to select architecture. If 32-bit is not available in that dropdown, you can add -m32 to the Additional Options box.

austin1howard
  • 4,815
  • 3
  • 20
  • 23
  • This answer ( http://stackoverflow.com/questions/1943681/linking-32-bit-library-to-64-bit-program ) is very similar to your question. – austin1howard Feb 03 '12 at 17:43