0

我正在尝试编译汇编代码。

我使用了命令

nasm -f coff myMergeSort.asm
gcc driver.c myMergeSort.o asm_io.o -o merge

但我收到以下错误:

myMergeSort.o: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status

我尝试使用“obj”代替“coff”,但它给出了类似的错误。

使用“elf”代替“coff”会出现以下错误:

myMergeSort.o: In function `main':
myMergeSort.asm:(.text+0x0): multiple definition of `main'
/tmp/cchbsJLl.o:driver.c:(.text+0x0): first defined here
/tmp/cchbsJLl.o: In function `main':
driver.c:(.text+0xa): undefined reference to `asm_main'
collect2: error: ld returned 1 exit status

我该如何解决?

4

1 回答 1

0

在 driver.c 中你可能调用了 asm_main,尝试添加 extern return_type asm_main(Type1 name1, ..., Typen namen);

其中 return_type 被函数的返回类型替换,typei 是编号为 i 的参数的类型。

于 2013-07-02T20:06:15.053 回答