简体   繁体   English

编译时未定义的'main'引用

[英]undefined reference to 'main' when compiling

Possible dup of this or this , but even after trying to dig through the answers for a while, I couldn't resolve this. 可能重复这个这个 ,但即使在试图挖掘答案一段时间后,我无法解决这个问题。

While trying to compile following makefile, 在尝试编译以下makefile时,

all:  test

    test:  constants.h Point.h Point.cpp line_t.h line_t.cpp drawing_t.h drawing_t.cpp clipper_t.h clipper_t.cpp main.cpp
        g++ -o test Point.cpp line_t.cpp drawing_t.cpp clipper_t.cpp main.cpp -lglut

I get an error: 我收到一个错误:

g++ -o test Point.cpp line_t.cpp drawing_t.cpp clipper_t.cpp main.cpp -lglut /usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/crt1.o: In function _start': (.text+0x18): undefined reference to main' collect2: ld returned 1 exit status make: *** [test] Error 1 g ++ -o test Point.cpp line_t.cpp drawing_t.cpp clipper_t.cpp main.cpp -lglut /usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu /crt1.o:在函数_start': (.text+0x18): undefined reference to text _start': (.text+0x18): undefined reference to主'collect2:ld返回1退出状态make:*** [test]错误1

I am new at Makefile. 我是Makefile的新手。 I guess, I am missing something too obvious. 我想,我错过了一些太明显的东西。

Apparently none your files define a function with the signature 显然,您的文件都没有定义带签名的函数

int main();

or 要么

int main(int argc, char *argv[]);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM