【发布时间】:2012-12-15 17:34:50
【问题描述】:
我正在尝试在 Assembler 上编译和链接我的第一个程序。 我尝试编译以下代码:
; %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 文件。 如何为我的系统正确编译程序?
【问题讨论】:
-
nasm 无法识别此选项
-
你运行的是什么版本的 nasm?
-
-bash-3.2$ nasm -v NASM 版本 0.98.40(Apple Computer, Inc. build 11)于 2012 年 8 月 4 日编译
-
那个版本的 nasm 已经过时了。看nasm.us/pub/nasm/releasebuilds/2.10