如何在64位MacBook终端上使用gcc编译32位应用程序

时间:2015-11-11 23:44:41

标签: macos assembly i386

所以我尝试运行.s文件,每次使用命令行时: gcc -m32 -o Compute32 Compute.s 我收到了这个错误:

Undefined symbols for architecture i386:
  "_main", referenced from:
     implicit entry/start for main executable
  "printf", referenced from:
      main in Compute-f6f555.o
  "scanf", referenced from:
      main in Compute-f6f555.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation

有人可以告诉我下一步吗?

1 个答案:

答案 0 :(得分:0)

我只能猜测,因为你没有告诉我你的Compute.s,但我想你的问题是在OS X上,所有C函数都在汇编中以下划线为前缀。因此,如果您将main更改为_main,同样将printf更改为_printf等,则应解决您的问题。