编译汇编(.s)文件一起iPhone项目 [英] Compiling Assembly (.S) file alongside iPhone project

查看:682
本文介绍了编译汇编(.s)文件一起iPhone项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的iPhone项目,我有一个名为arm_asm_stub.S汇编文件,其中包含一个方法,我需要从另一个文件在我的项目叫main.c中调用当我不#包括我的main.c文件的顶部的文件,我得到没有生成错误,但我得到的链接器错误:

In my iPhone project, I have an assembly file named arm_asm_stub.S, which contains a method I need to call from another file in my project called main.c. When I don't #include the file at the top of my main.c file, I get no build errors, but I do get the linker error:

Undefined symbols for architecture armv7:
  "_execute_arm_translate", referenced from:
      _iphone_main in main.o

然而,当我尝试#包括该文件在main.c中的顶部,X code使用锵编译arm_asm_stub.S,所以我得到了一堆错误,那些中没有出现,当我不要将文件#包括如:

However, when I attempt to #include the file at the top of main.c, Xcode uses Clang to compile arm_asm_stub.S and so I get a bunch of errors, ones that don't appear when I don't #include the file such as:

unknown type name 'ldr'
expected identifier or '('
use of undeclared identifier 'sp'

如何能X $ C $Ç比项目的其余部分单独编译此文件时?

How can Xcode compile this one file separately than the rest of the project?

推荐答案

您应该只是添加 .S 文件到您的项目和构建系统将自动组装。小心尽管符号。所有的C函数都被编译器ppended给他们一个下划线$ P $,所以你的汇编语言程序标签需要在前端对C code下划线才能够调用它。

You should just add the .S file to your project and the build system will automatically assemble it. Be careful with the symbols though. All C functions have an underscore prepended to them by the compiler, so your assembly language routine label needs an underscore at the front for C code to be able to call it.

这篇关于编译汇编(.s)文件一起iPhone项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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