我正在阅读“c/c++ 开发指南”下的“入门”帮助,并且被困在 makefile 中......不是很远。我不是 c 或 c++ 的新手,但我是 eclipse 和 makefile 的新手。
我去这里下载了 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)
,现在它工作正常。
感谢任何/所有人的时间。