问题
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
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?
回答1:
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.
来源:https://stackoverflow.com/questions/46039667/link-object-files-without-libsystem-macos