ld:在Mac OS X上为不支持的文件格式构建了文件 [英] ld: file was built for unsupported file format on Mac OS X

查看:279
本文介绍了ld:在Mac OS X上为不支持的文件格式构建了文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须使用在另一台x64_86计算机上编译的共享对象来构建一个项目.我有这个错误:

I have to build a project with shared objects compiled on a other x64_86 computer. I have this error:

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计算机上运行.

The architecture of my Mac is x86_64 and shared objects were compiled on a x86_64. The compilation works on my Linux computer.

这是我的Makefile:

Here my 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并生成

You cannot do that as this "other x86_64 computer" was clearly running Linux and generating ELF-format object files.

0x7F 0x45 0x4C 0x46
0x7F 'E'  'L'  'F'

OSX/iOS使用 Mach-O格式对象文件,无法针对不同的对象进行链接对象文件的类型.

OSX/iOS uses Mach-O format object files and cannot be linked against different types of object file.

您将需要在OSX下编译所有代码.

You will need to compile all the code under OSX.

这篇关于ld:在Mac OS X上为不支持的文件格式构建了文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆