Compile a binary file for linking OSX

Posted by Satpal on Stack Overflow See other posts from Stack Overflow or by Satpal
Published on 2012-01-19T08:35:15Z Indexed on 2012/12/07 23:05 UTC
Read the original article Hit count: 217

Filed under:
|
|
|

I'm trying to compile a binary file into a MACH_O object file so that it can be linked it into a dylib. The dylib is written in c/c++.

On linux the following command is used: ld -r -b binary -o foo.o foo.bin

I have tried various option on OSX but to no avail:

ld -r foo.bin -o foo.o
gives:
ld: warning: -arch not specified
ld: warning: ignoring file foo.bin, file was built for unsupported file format which is not the architecture being linked (x86_64)

An empty .o file is created

ld -arch x86_64 -r foo.bin -o foo.o 
ld: warning: ignoring file foo.bin, file was built for unsupported file format which is not the architecture being linked (x86_64)

Again and empty .o file is created. Checking the files with nm gives: nm foo.o nm: no name list

The binary file is actually, firmware that will be downloaded to an external device.

Thanks for looking

© Stack Overflow or respective owner

Related posts about osx

Related posts about binary-data