1

I have two libraries, one is called liblits.so, which is 32bits, another one is called liblinx.a, which is 64bits. I need to link both of them, in my Makefile, after adding CFLAGS += "-m32", I got error:

skipping incompatible liblinx.a when searching for -llinx 

but there was no error for liblits.so. If I remove CFLAGS += "-m32"(my machine is 64bits), I got error:

skipping incompatible liblits.so when searching for -llits

but there was no error for liblinx.a. How can I link the 32bits library and 64bits library at the same time? Or do I have to have two consistent libraries?

My Makefile:

CFLAGS = -I.
CFLAGS += "-m32" 
LDFLAGS = -Llinx -llinx -Llib -llits -lrt -lpthread -Wl,-R,'lib' 
server:server.c
    gcc -o server $(CFLAGS) $(LDFLAGS) server.c 
betteroutthanin
  • 7,148
  • 8
  • 29
  • 48

1 Answers1

3

You need consistent libraries. The machine code in the 32- and 64-bit libraries is incompatible -- you have different pointer sizes, for example, leading to a different expectation of the size of the virtual address space and similar problems.

How would you make an object outside the 4GB a 32-bit pointer can address but that a function in the 64-bit library can create known to a function in the 32-bit library? It's impossible, and for reasons like these and many others, so is linking 32- and 64-bit libraries to the same binary.

Wintermute
  • 42,983
  • 5
  • 77
  • 80