我正在尝试使用gcc在debian机器上编译此简单的C文件:
#include <stdio.h>
char * my_name = "My Name";
extern unsigned int simple_op(unsigned int a, unsigned int b);
void main() {
unsigned int a, b, result;
printf("Simple op demo by %s at %s %s\n", my_name, __DATE__, __TIME__);
printf("Please input a : ");
scanf("%u", &a);
printf("Please input b : ");
scanf("%u", &b);
result = simple_op(a, b);
printf("simple_op(%u, %u) = %u(0x%08x)\n", a, b, result, result);
}
使用以下程序集文件:
.text
.global simple_op
.type simple_op, @function
simple_op:
add $v0,$a0,$a1
jr $ra
但是当我尝试汇编上述文件时,出现此错误:
In function `__start':
(.text+0x1c): undefined reference to `main'
collect2: error: ld returned 1 exit status
不允许我编译C文件。我该如何解决?