Xcode 在OS X上将NASM文件拆分为多个,并出现链接错误

Xcode 在OS X上将NASM文件拆分为多个,并出现链接错误,xcode,assembly,clang,nasm,libtool-xcode,Xcode,Assembly,Clang,Nasm,Libtool Xcode,我的基本汇编程序文件foidlrt.asm开始变得有点太大,所以我把它分成了两部分。下面是第二个文件文件夹\u stdio.asm的全部内容: ; foidl_stdio.asm %include "foidlstnd.inc" section .text DEFAULT REL global foidl_fclose ; Raw file close ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

我的基本汇编程序文件
foidlrt.asm
开始变得有点太大,所以我把它分成了两部分。下面是第二个文件
文件夹\u stdio.asm的全部内容:

; foidl_stdio.asm

%include   "foidlstnd.inc"


        section .text

        DEFAULT REL

global foidl_fclose           ; Raw file close

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; foidl_close
; Raw file close
; REGISTERS (1):
; RDI file handle
; CALLS:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

foidl_fclose:
    mov       rax,SYSCALL_FILE_CLOSE  ; 0x2000006
    syscall
    ret
然而,现在当我构建时,尽管新文件中有
global
声明,但我现在从make得到了这个错误:

nasm src/foidlrt.asm -f macho64 --prefix _ -g -O0 -Iincludes/ -o asmobjs/foildrt.o
nasm src/foidlrt.asm -f macho64 --prefix _ -g -O0 -Iincludes/ -o asmobjs/foidl_stdio.o
libtool -static -s -o libs/libfoidlrt.a asmobjs/foildrt.o asmobjs/foidl_stdio.o
gcc src/testlink.c -L libs -l foidlrt -Wall -g -L. -Wl,-pie -I. -o bin/testlink
Undefined symbols for architecture x86_64:
  "_foidl_fclose", referenced from:
      _main in testlink-4b5ad3.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
版本信息:

XCode - 7.2.1 (7C1002)
nasm  - NASM version 2.12 compiled on Feb 28 2016
gcc   - Apple LLVM version 7.0.2 (clang-700.1.81)
已解决

错误都是我的,makefile规则不好。现在正在按预期工作


您是否在另一个源文件中将
foidl\u fclose
声明为
extern
?我将其声明为extern
testit.c
以及
foidl.asm
均无效。正如错误消息所述,显然您需要在符号名称上加一个前导下划线。因此,将您的
foidl\u fclose
更改为
\u foidl\u fclose
@Jester,我在nasm编译中用
--前缀在两个文件中设置了它。当它只是一个文件时,它就正常工作了。@Jester-这是我的规则。如果您查看make输出,它是重新编译
foidlrt.asm
输出到
foidl\u stdio.o
。用户错误!