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
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.