我需要在另一台64位计算机上编译共享对象,并构建一个项目。但是我遇到了以下错误:
cc -std=c11 -Wall -Werror -Wextra -pedantic -I./include src/server.c
obj/tftp.o -o bin/server -L./lib64 -lSocketUDP -lAdresseInternet -lpthread
ld: warning: ld: warning: ignoring file ./lib64/libSocketUDP.so, file was
built for unsupported file format ( 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 ) which is not the architecture
being linked (x86_64): ./lib64/libSocketUDP.soignoring file
./lib64/libAdresseInternet.so, file was built for unsupported file format (
0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 ) which is not the architecture being linked (x86_64):
./lib64/libAdresseInternet.so
我的Mac的架构是x86_64,共享对象是在x86_64上编译的。这个编译可以在我的Linux电脑上运行。
这是我的Makefile:
CFLAGS = -std=c11 -Wall -Werror -Wextra -pedantic -I./include
LDLIBS = -L./lib64
LDFLAGS = -lSocketUDP -lAdresseInternet -lpthread
all: obj/tftp.o bin/server bin/client
obj/tftp.o: src/tftp.c
mkdir -p obj
$(CC) $(CFLAGS) -c $^ -o $@
bin/server: src/server.c obj/tftp.o
mkdir -p bin
$(CC) $(CFLAGS) $^ -o $@ $(LDLIBS) $(LDFLAGS)
bin/client: src/client.c obj/tftp.o
mkdir -p bin
$(CC) $(CFLAGS) $^ -o $@ $(LDLIBS) $(LDFLAGS)
clean:
$(RM) -r obj
distclean:
$(RM) -r obj bin
谢谢。