{"id":1207,"date":"2022-08-30T15:14:10","date_gmt":"2022-08-30T15:14:10","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/10\/compiling-assembly-s-file-alongside-iphone-project-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:14:10","modified_gmt":"2022-08-30T15:14:10","slug":"compiling-assembly-s-file-alongside-iphone-project-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/compiling-assembly-s-file-alongside-iphone-project-collection-of-common-programming-errors\/","title":{"rendered":"Compiling Assembly (.S) file alongside iPhone project-Collection of common programming errors"},"content":{"rendered":"<p>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&#8217;t #include the file at the top of my main.c file, I get no build errors, but I do get the linker error:<\/p>\n<pre><code>Undefined symbols for architecture armv7:\n  \"_execute_arm_translate\", referenced from:\n      _iphone_main in main.o\n<\/code><\/pre>\n<p>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&#8217;t appear when I don&#8217;t #include the file such as:<\/p>\n<pre><code>unknown type name 'ldr'\nexpected identifier or '('\nuse of undeclared identifier 'sp'\n<\/code><\/pre>\n<p>How can Xcode compile this one file separately than the rest of the project?<\/p>\n<ol>\n<li>\n<p>You should just add the <code>.S<\/code> 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.<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-11-10 00:09:51. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>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&#8217;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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1207","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1207","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1207"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1207\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1207"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}