2010-05-07 113 views
1

我有一個目標文件,我想將它製作成Mach-O二進制文件(我在Mac OS 10.6上)。運行ld -e _main source.o /usr/lib/libc.dylib產生以下輸出:如何從目標文件製作Mach-O二進制文件?

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

我怎麼可以參考的libc,在使用ld?

回答

2

您需要添加到ld調用對象文件調用的庫 - 靜態或動態的形式。對於printf,特別是,我認爲你想要/usr/lib/libc.dylib

+0

如果我做'ld -e _main source.o /usr/lib/libc.dylib',我得到'ld:symbol dyld_stub_binding_helper沒有定義(通常在crt1.o/dylib1.o/bundle1.o中)體系結構x86_64'。 – Mike 2010-05-07 03:37:15

+0

@Mike,所以你還需要''ld'命令行中的'/ usr/lib/crt1.o'。 – 2010-05-07 03:43:53

+0

鏈接工作,但我得到一個段錯誤: 編程接收到的信號EXC_BAD_ACCESS,無法訪問內存。 原因:13在地址:0x0000000000000000 0x00007fff5fc0ff75在__dyld_stub_binding_helper_interface() – Mike 2010-05-07 03:50:01