C++代码
代码
/*
* main.cpp
*/

#include
<iostream>
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);
}

 

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


注意,makefile里的行首缩进用的是Tab而不是空格。如果编译时提示 No separator...就是这里有问题。

9. Ok, 选中工程,点Build(或点那个小锤子),你会发现这个错误:(Cannot run program "make": Launching failed),啊,我们的make.exe还没设。选中工程,直接Alt-Enter到工程属性页,把msys的bin加到Path里。
Windows下用Eclipse搭建C/C++开发环境 

10. 重新build, 大功告成。

相关文章: