无法在控制台中看到c ++程序的输出 [英] unable to see the output of c++ program in the console

查看:105
本文介绍了无法在控制台中看到c ++程序的输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的Windows 8笔记本电脑上安装了eclipse ide(cdt),并尝试编写一个简单的c程序来检查程序是否执行。



并给出错误: binary not found



所以我做了一些在线搜索,意识到我的系统没有已安装ac / c ++编译器。

所以我安装了MinGW并在安装过程中选择了c和c ++编译器。

然后我将PATH环境变量设置为C:\MinGW。 br>
我重新打开了eclipse,编写了一个简单的c程序,并且按预期工作!



我创建了一个c ++项目,写了一段简单的代码,看不到控制台中的输出!



以下是代码:

 #include< iostream> 
using namespace std;

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


解决方案

)>添加命令(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;

这篇关于无法在控制台中看到c ++程序的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆