在没有libSystem macOS的情况下链接目标文件 [英] Link object files without libSystem macOS

查看:668
本文介绍了在没有libSystem macOS的情况下链接目标文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在x86-64上为macOS编写编译器,但是当我将目标文件链接在一起时,ld

I'm writing a compiler for macOS on x86-64, but when I link the object files together, ld says

ld: dynamic main executables must link with libSystem.dylib for inferred architecture x86_64

但是由于libSystem包含libc,所以我不想使用它(它会给我很多重复项).我该如何解决?

But since libSystem contains libc, I don't want to use it (it would give me lots of duplicates). How can I get around this?

推荐答案

使用-macosx_version_min 10.6作为ld参数.这将在可执行文件中生成LC_UNIXTHREAD而不是LC_MAIN.如果您想进一步控制,则需要完全消除链中的ld.

Use -macosx_version_min 10.6 as ld parameter. This will generate LC_UNIXTHREAD instead of LC_MAIN in your executable. If you want even more control you'd need to get rid of ld in your chain altogether.

这篇关于在没有libSystem macOS的情况下链接目标文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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