我想編譯並鏈接我的彙編程序上的第一個程序。 我嘗試編譯下面的代碼:如何在MacOSX上使用nasm編譯
; %include "stud_io.inc"
global _main
section .text
_main:
xor eax, eax
again:
; PRINT "Hello"
; PUTCHAR 10
inc eax
cmp eax, 5
jl again
下面的控制檯命令編譯和連接的程序:
-bash-3.2$ nasm -f macho main.asm -o main.o && ld -e _main -macosx_version_min 10.8 -arch x86_64 main.o
但結果是:
ld: warning: ignoring file main.o, file was built for i386 which is not the architecture being linked (x86_64): main.o
Undefined symbols for architecture x86_64:
"_main", referenced from:
-u command line option
ld: symbol(s) not found for architecture x86_64
我認爲它的必要編譯x86_64的main.asm文件.. 如何正確編譯我的系統的程序?
'-f macho64'也許? – JasonD
nasm無法識別此選項 –
您運行的是哪個版本的nasm? – JasonD