求makefile写法 生成动态库的
这是我的makefile
CC := mipsel-linux-gcc
LD := ld
CFLAGS :=
LDFLAGS := -shared -fpic
SOURCE := $(wildcard *.c)
OBJS := $(patsubst %.c,%.o,$(SOURCE))
TARGET_LIB := qrencode.so
all:$(OBJS)
echo $(OBJS)
$(LD) $(LDFLAGS) -o $(TARGET_LIB) $(OBJS)
%.o:%.c
@echo Compiling $< ...
$(CC) -c $(CFLAGS) $< -o $*.o
.PHONY: clean
clean:
rm *.so *.o -rf
我make之后
Compiling bitstream.c ...
mipsel-linux-gcc -c bitstream.c -o bitstream.o
Compiling mask.c ...
mipsel-linux-gcc -c mask.c -o mask.o
Compiling mmask.c ...
mipsel-linux-gcc -c mmask.c -o mmask.o
Compiling mqrspec.c ...
mipsel-linux-gcc -c mqrspec.c -o mqrspec.o
Compiling qrencode.c ...
mipsel-linux-gcc -c qrencode.c -o qrencode.o
Compiling qrinput.c ...
mipsel-linux-gcc -c qrinput.c -o qrinput.o
Compiling qrspec.c ...
mipsel-linux-gcc -c qrspec.c -o qrspec.o
Compiling rscode.c ...
mipsel-linux-gcc -c rscode.c -o rscode.o
Compiling split.c ...
mipsel-linux-gcc -c split.c -o split.o
echo bitstream.o mask.o mmask.o mqrspec.o qrencode.o qrinput.o qrspec.o rscode.o split.o
bitstream.o mask.o mmask.o mqrspec.o qrencode.o qrinput.o qrspec.o rscode.o split.o
ld -shared -fpic -o qrencode.so bitstream.o mask.o mmask.o mqrspec.o qrencode.o qrinput.o qrspec.o rscode.o split.o
ld: bitstream.o: Relocations in generic ELF (EM: 8)
ld: bitstream.o: Relocations in generic ELF (EM: 8)
bitstream.o: could not read symbols: File in wrong format
我用的是交叉编译 不懂什么原因 我猜测是 我的代码 用到了另外个 系统动态库。 所以不行 我该怎么做呢。