且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法在控制台中看到c ++程序的输出

更新时间:2022-10-26 23:33:36

)>添加命令(g ++ -static-libgcc -static-libstdc ++)



这不是正确的解决方案。



您的路径环境变量中只有 c:\minGW

但它应该是 c:\minGW; c:\minGW\bin 。 (在打开eclipse之前设置PATH)



因此,当前程序需要的 libstdc ++ - 6.dll 找不到。



在eclipse中没有错误,但在控制台中没有输出! b $ b

它编译进程序可能被视为一个伎俩,但将只适用于标准库






您的链接器标志不应设置为:



- > MinGW C ++链接器-libgcc -static-libstdc ++)



应在此处设置:








我知道在这种情况下,不必在结束<< endl 来写。

一个好的编程风格应该使用<< endl

  cout< 样本文本<< endl; 


I have installed the eclipse ide(cdt) on my windows 8 laptop and tried writing a simple c program to check whether the program executes.

It did not execute and gave the error : binary not found .

So I did some searching online and realized that my system did not have a c/c++ compiler installed.
So I installed MinGW and selected the c and c++ compilers during installation.
Then I set the PATH environment variable to C:\MinGW.
I reopened eclipse, wrote a simple c program and it worked as expected!

I created a c++ project, wrote a simple piece of code and could not see the output in the console!

Here is the code:

#include<iostream>
using namespace std;

int main()
{
    cout<<"sample text";
    return 0;
}

Linker (Option) > Add Command (g++ -static-libgcc -static-libstdc++)

This is not the right solution.

You have in your path environment variable only c:\minGW .
But it should be c:\minGW;c:\minGW\bin . (Set the PATH before open eclipse)

Therefore, libstdc++-6.dll needed by the current program, can not be found.

In eclipse there is no error, but no output in the console !!

It to compile into the program may be regarded as a trick, but will only work for the standard libs .


your linker flags should not be set like :

--> MinGW C++ Linker (Option) > Command (g++ -static-libgcc -static-libstdc++)

should be set here :


I know in this case it is not necessary at the end << endl to write.
A good programming style should use << endl :

cout << "sample text" << endl;