在Mac OS上的nasm中编译汇编程序 [英] Compile assembler in nasm on mac os

查看:288
本文介绍了在Mac OS上的nasm中编译汇编程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我在asm上写了一些指令,并对其进行了编译.

So, i write some instruction on asm, and compile them.

nasm -f macho test.asm

现在,nasm生成obj文件test.o

Now, nasm generate obj file, test.o

gcc test.o 

返回下一个错误:

  • ld:警告:忽略文件test.o,该文件是为不支持的文件构建的 格式,不是链接的架构(x86_64)
  • 未定义 架构x86_64的符号:"_ main",引用自:
  • 从crt1.10.6.o开始ld:找不到体系结构x86_64 collect2的符号:ld返回1退出状态
  • ld: warning: ignoring file test.o, file was built for unsupported file format which is not the architecture being linked (x86_64)
  • Undefined symbols for architecture x86_64: "_main", referenced from:
  • start in crt1.10.6.o ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status

在gcc行中,我使用了-arch i386(x86_64),返回了相同的错误.

in gcc line, i used -arch i386 (x86_64), returned same error.

有人可以帮忙吗? :)

Can anybody help? :)

推荐答案

这些命令对我有用(OS X 10.12 x64):

These commands work for me (OS X 10.12 x64):

nasm -f macho test.asm -DDARWIN
ld -o test test.o -arch i386 -lc -no_pie -macosx_version_min 10.12 -lSystem

这篇关于在Mac OS上的nasm中编译汇编程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆