Eclipse CDT控制台输出不显示在带有路径的调试中,并且在没有路径的情况下不显示 [英] Eclipse CDT Console output not showing up in debug with path and not showing up in run without path

查看:533
本文介绍了Eclipse CDT控制台输出不显示在带有路径的调试中,并且在没有路径的情况下不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让Eclipse CDT(64位eclipse)在带有GCC的Windows 7上工作。当我第一次得到GDB工作(这本身就是一个挑战),运行程序在调试模式是我得到输出的唯一方法。运行它通常没有给任何控制台输出。谷歌搜索后,我想出,如果我添加了C:/ cygwin / bin到我的环境路径在eclipse,我可以得到输出,当运行程序正常。然后我在调试模式下运行它,没有输出。我测试了这个几次,以确保它是添加的路径导致的问题。这是我运行的程序,

I'm trying to get Eclipse CDT (64 bit eclipse) working on Windows 7 with GCC. When I first got GDB working (that was a challenge in itself), running the program in debug mode was the only way I got output. Running it normally didn't give any console output. After hours of googling, I figured out that if I added C:/cygwin/bin to my environment path in eclipse, I could get output when running the program normally. Then I ran it in debug mode and there was no output. I tested this a couple of times to make sure it was the addition of the path causing the problem. This is the program I was running,

#include <iostream>

using namespace std;

int main() {
    cout << "Hello World!" << endl;
    return 0;
}

那么如何让正常和调试模式工作,首先必须包括该路径(它已经在我的cygwin路径,为什么CDT需要它?)?此外,为什么如果我添加一个路径到我的运行配置它也将添加到我的调试配置?

So how can I get both normal and debug modes working, and why did I have to include that path in the first place (it's already in my cygwin path and why does CDT need it?) ? Also, why is it that if I add a path to my Run configurations it will also be added to my Debug configurations?

推荐答案

我不认为我可以回答一切,但我使用完全相同的设置,你和我不得不处理这样的很多问题(我想知道如果你有麻烦如何使用32- bit / 64位JVM和Internet浏览)!

I don't think I can answer everything but I use exactly the same set-up as you and I've had to deal with quite a few issues like this (I'm wondering if you had trouble how to juggle using the 32-bit/64-bit JVM and Internet browsing)!

必须指定cygwin / bin路径,因为这是gcc,gdb和所有其他cygwin工具和dll (我假设你使用cygwin风味的gcc而不是MinGW风味)。我相信你必须在Windows环境中指定它(使用win32文件路径),因为Eclipse正在使用Windows JVM运行,因此处理win32路径。因此,在cygwin环境中的 PATH 变量中添加 cygwin / bin CDT正在使用Eclipse寻找cygwin,Eclipse需要从Windows找到cygwin1.dll。

The cygwin/bin path must be specified because that is where gcc, gdb and all the other cygwin tools and dlls are located (I'll assume you're using cygwin flavour of gcc rather than MinGW flavour). I believe you must specify it in the Windows environment (using a win32 file path) because Eclipse is running using the Windows JVM and therefore deals with win32 paths. Consequently, it doesn't matter that cygwin/bin is added to the PATH variable in the cygwin environment. CDT is looking for cygwin using Eclipse, and Eclipse needs to find cygwin1.dll from Windows.

我可能完全错了,但如果我不得不猜测,你需要确保你已经正确设置了 PATH 环境变量的两个配置。

I might be totally wrong, but if I had to guess I would say that you need to make absolutely sure you have properly set the PATH environment variable correctly for both configurations.

请注意,在Eclipse中,在调试配置窗口中显示的配置与运行配置窗口中具有相同名称的配置之间存在无差别 。两个窗口之间的唯一区别是,一个将运行程序,而不使用调试器,并有用于设置调试设置的选项卡。因此,改变一个设置也会影响另一个设备,这并不奇怪。

One thing to note is that in Eclipse there is no difference between a configuration shown in the Debug Configurations window and one with the same name in the Run Configurations window. The only difference between the two windows is that one will run the program without using a debugger and has tabs for setting debug settings. Therefore it's no surprise that changing settings in one will also affect the other.

您可能知道,对于许多项目,构建系统设置为产生两个)组二进制文件:一个具有调试信息/符号(DEBUG),一个没有(RELEASE)。在这种情况下,通常在Eclipse中有两个配置:一个运行DEBUG二进制,一个运行RELEASE二进制。这两个都会显示在调试配置窗口和运行配置窗口中。关键是你可以使用或不使用gdb来运行DEBUG,但是gdb不能使用RELEASE。

As you may know, for many projects the build system is set up to produce two (sometimes more) sets of binaries: one with debugging info/symbols (DEBUG) and one without (RELEASE). In this case, you normally have two configurations in Eclipse: one to run the DEBUG binary and one to run the RELEASE binary. Both of these will show up in both the Debug Configurations window and in the Run Configurations window. The point is that you can run DEBUG either with or without gdb, but RELEASE cannot be used by gdb.

也就是说,我不确定为什么要添加正确的路径到运行配置将停止DEBUG二进制输出到控制台。我怀疑其他的东西在这里,可能是调试信息和调试器不匹配。

That said, I'm not sure why adding the correct path to the run configuration would stop the DEBUG binary from outputting to the console. I suspect something else is going on here, perhaps a mismatch of debug info and debugger.

到(希望)回答你的问题,如何使两个配置工作,整个hog并只需添加 C:\cygwin\bin; 到Windows PATH 环境变量。我猜这将允许两者工作。我会假设你知道如何做,但请不要发表评论。

To (hopefully) answer your question as to how to get both configurations working, go the whole-hog and just add C:\cygwin\bin; to the Windows PATH environment variable. I'm guessing that will allow both to work. I'll assume you know how to do that but please post a comment if not.

另一件事是从cygwin shell编译和运行程序。如果它在那里工作,这可能是一个安全的赌注,您的 PATH 环境变量使用eclipse时未正确设置。

The other thing to try would be to compile and run the program from a cygwin shell. If it works there it's probably a safe bet that your PATH environment variable is not set correctly when using eclipse.

希望有所帮助!

这篇关于Eclipse CDT控制台输出不显示在带有路径的调试中,并且在没有路径的情况下不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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