Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Gcc 汇编代码编译错误:无法识别文件_Gcc_Assembly_Cross Compiling_Nasm - Fatal编程技术网

Gcc 汇编代码编译错误:无法识别文件

Gcc 汇编代码编译错误:无法识别文件,gcc,assembly,cross-compiling,nasm,Gcc,Assembly,Cross Compiling,Nasm,我正在尝试编译一个汇编代码 我使用命令 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 myMergeSort.o: In function `main': my

我正在尝试编译一个汇编代码

我使用命令

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
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
我试着用“obj”代替“coff”,但它给出了一个类似的错误

使用“elf”代替“coff”会产生以下错误:

myMergeSort.o: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status
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

如何修复它?

在driver.c中,您可能打电话到asm\u main,请尝试添加 外部返回类型asm\U main(类型1名称1,…,类型N名称)

其中,return_type被函数的返回类型替换,typei是类型
是的,我试过使用elf,它给出了错误“main的多个定义”,就像我在问题中发布的那样谁的代码是driver.c?看起来它希望程序集代码导出名为
asm_main
的函数,而不是
main