undefined reference to `main`
新建一个C++测试程序,调用编译指令:
g++ -c test.c
g++ -o test test.o
后出现如下错误,
/usr/lib/gcc/i686-linux-gnu/4.7/http://www.cnblogs.com/../i386-linux-gnu/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: error: ld returned 1 exit status
经查发现是因为入口main函数写错,我的入口为int main(),但因为我建的C++工程,所以入口应为int main(int argc, char* argv[] ),
改正之后,错误消失。
经查: 该问题不是上述原因,是因主文件未保存,上次解决可能是因为更改后,点击了保存,这才解决了问题。