Eclipse CDT - Hello World Empty Makefile项目

时间:2011-05-01 17:35:34

标签: makefile eclipse-cdt build-error

  

可能重复:
  undefined reference to WinMain Error 1 in eclipse using mingw

我正在通过'c / c ++开发指南'中的'入门'帮助,并且被困在makefile中......不是很远。我不是c或c ++的新手,但我是eclipse和makefiles的新手。

我去了Here并下载了wascana setup.exe并运行它进行安装。这是Helios发布。我也在运行Windows 7。

我能够构建并运行'hello world'模板,我已经玩了一下。但现在我正在关注makefile教程,我的项目将无法构建。我收到这个错误:

make all
g++ -g -o hello main.o
c:/wascana/mingw/bin/../lib/gcc/mingw32/4.4.1-dw2/../../../libmingw32.a(main.o):main.c:
(.text+0xd2): undefined reference to 'WinMain@16'
collect2: ld returned 1 exit status
make: *** [hello.exe] Error 1

我按照说明逐字记录,将所有内容命名为相同等等。我回去复制/粘贴我所能保证的工作是一样的,但仍然无法构建。

编辑:这是main.cpp

#include
using namespace std;

int main () {
// Say Hello five times
for (int index = 0; index < 5; ++index)
cout << "HelloWorld!" << endl;
char input = 'i';
cout << "To exit, press 'm'" << endl;
while(input != 'm') {
cin >> input;
cout << "You just entered " << input
<< " you need to enter m to exit." << endl;
}
exit(0);
}

Aaaand这里是make文件(虽然我有适当的标签)。

all: hello.exe
clean:
rm main.o hello.exe
hello.exe: main.o
g++ -g -o hello main.o
main.o:
g++ -c -g main.cpp

编辑:

得到了..

当我输入exit(0)时,我觉得这很奇怪。我把它切换到return(0),现在它工作正常。

感谢您的所有时间。

0 个答案:

没有答案