我正在尝试使用以下命令使用gcc运行hello world程序
gcc hello.c
但是我收到以下错误。
/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status
答案 0 :(得分:1)
似乎您在main()
中没有定义hello.c
功能。正确的代码是这样的:
#include <stdio.h>
int main(int argc, char**argv) /// <<==-- here is a correct definition
{
printf("Whatever you want\n");
return 0;
}