Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make a Mach-O binary from an object file?

Tags:

macos

linker

I have an object file, which I'd like to make into a Mach-O binary(I'm on Mac OS 10.6). Running ld -e _main source.o /usr/lib/libc.dylib produces the following output:

ld: symbol dyld_stub_binding_helper not defined (usually in crt1.o/dylib1.o/bundle1.o) for inferred architecture x86_64

How can I reference libc using ld?

like image 436
Mike Avatar asked Mar 03 '26 01:03

Mike


1 Answers

You'll need to add to the ld invocation the libraries that your object file calls to -- in static or dynamic form. For printf, in particular, I think you want /usr/lib/libc.dylib.

like image 82
Alex Martelli Avatar answered Mar 05 '26 18:03

Alex Martelli