> /usr/lib/gcc/i386-redhat-linux/4.0.0/../../../crt1.o(.text+0x18): In
> function `_start':
> : undefined reference to `main'
> collect2: ld returned 1 exit status
Exactly what the error message tells you: there's no main() function.
Actually, this is an error message from the linker that tries to
assenmble the final executable. And during that it finds that there's
no main() function in any of the object files it's linking together
to create the program. Since you don't tell mnore about when that
happens my best guess at the moment is that you actually only want to
compile one of a number of source files into an object file but not
already link. This, in turn, can happen if you call gcc, forgetting
about the '-c' option - without this option gcc tries not only to
compile, but also to link the program.
本文解决了一个常见的编译错误,即链接阶段出现的“未定义的 main 函数”错误。此问题通常发生在尝试编译一个没有 main 函数的 C 或 C++ 程序时。文章详细解释了错误发生的原因,并提供了如何正确使用 gcc 编译器选项来避免此问题的方法。
688

被折叠的 条评论
为什么被折叠?



