我必须使用在其他 x64_86 计算机上编译的共享对象来构建一个项目。我有这个错误:
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
谢谢。
你不能这样做,因为这台“其他 x86_64 计算机”显然正在运行 Linux 并生成ELF格式 https://en.wikipedia.org/wiki/Executable_and_Linkable_Format对象文件。
0x7F 0x45 0x4C 0x46
0x7F 'E' 'L' 'F'
OSX/iOS 使用马赫-O 格式 https://en.wikipedia.org/wiki/Mach-O目标文件,并且不能链接到不同类型的目标文件。
您需要在 OSX 下编译所有代码。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)