我正在使用Windows 7 64位.
我安装了eclipse版本3.6.2,cdt和MinGW.我在Eclipse中有一个C控制台程序,如下所示:
#include <iostream> #include <cstdio> using namespace std; int main() { setbuf(stdout,NULL); for (int i = 0; i < 10000000; i++) { cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!! } int val; cin >> val; return 0; }
如果我运行这个控制台程序,它应该在Eclipse中显示控制台视图的Hello world,但不显示任何内容.
如果我去调试文件夹并运行exe,它会打印到控制台.
如果我犯了一些语法错误,那么Eclipse Console View会显示一些东西,比如:
**** Internal Builder is used for build **** g++ -O0 -g3 -Wall -c -fmessage-length=0 -osrc\hh.o ..\src\hh.cpp ..\src\hh.cpp: In function 'int main()': ..\src\hh.cpp:17:3: error: expected ';' before 'return' Build error occurred,build is stopped Time consumed: 255 ms.
我发现这个网站的解决方法:
http://www.eclipse.org/forums/index.php?=42e862594001fa4469bbc834885d545f&t=msg&th=197552
http://www.eclipse.org/forums/index.php?=42e862594001fa4469bbc834885d545f&t=msg&th=197552
在那个链接中,看看“没有真实姓名”的答复.
Environment: jdk1.6u18 64bit + Eclipse Helios 64bit + win7 64bit No console output at "Run",but output correctly at "Debug". The following method worked for me: 1. Goto Project->Properties->Run/Debug Settings,choose the .exe file and press "Edit" 2. In the "Environment" tag,press "New",set it as: "Name:PATH" "Value:C:\MinGW\bin" In fact,I have already set "C:\MinGW\bin" in windows PATH environment variable,but it seemed to not work.