C链接错误:未定义对"main"的引用 [英] C Linking Error: undefined reference to 'main'
本文介绍了C链接错误:未定义对"main"的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经阅读了有关该主题的其他答案,但不幸的是,它们并没有帮助我.我试图将多个C程序链接在一起,但在响应时出现错误:
I have read the other answers on this topic, and unfortunately they have not helped me. I am attempting to link several c programs together, and I am getting an error in response:
$ gcc -o runexp.o scd.o data_proc.o -lm -fopenmp
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: ld returned 1 exit status
make: * [runexp] Error 1
我只有一个主要功能,它在runexp中.表格是
I have exactly one main function and it is in runexp. The form is
int main(void) {
...;
return 0;
}
关于为什么会出现此错误的任何想法?谢谢!
Any thoughts on why I might get this error? Thanks!
推荐答案
您应该在-o
选项之后提供输出文件名.在您的情况下,runexp.o
被视为输出文件名,而不是输入目标文件,因此您的main
函数未定义.
You should provide output file name after -o
option. In your case runexp.o
is treated as output file name, not input object file and thus your main
function is undefined.
这篇关于C链接错误:未定义对"main"的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文