eclipse windows下如何让gdb与Eclipse CDT一起工作(找不到源代码)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17267632/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get gdb working with Eclipse CDT under windows (fails to find source code)
提问by Dov
I installed cygwin (the latest 1.7.xx?), and then installed eclipse cdt (Juno).
我安装了cygwin(最新的1.7.xx?),然后安装了eclipse cdt(Juno)。
When I tried to build a hello world project, despite eclipse identifying that cygwin was installed, it didn't work.
当我尝试构建一个 hello world 项目时,尽管 eclipse 识别出安装了 cygwin,但它没有工作。
So I manually added c:\cygwin\bin to the path, which found all the executables in cygwin, including g++, make ld, etc.
所以我手动添加了c:\cygwin\bin到路径中,找到了cygwin中的所有可执行文件,包括g++、make ld等。
Now, eclipse can build the project, but when debugging, gdb starts up and can't find the source code. It claims that it can't find:
现在eclipse可以构建项目了,但是调试的时候gdb启动了,找不到源码。它声称找不到:
/cygdrive/c/users/me/workspace/test1/test1.cc . even though that's exactly where it is. It's as though cygwin's directory system doesn't work.
/cygdrive/c/users/me/workspace/test1/test1.cc 。即使那正是它所在的位置。就好像 cygwin 的目录系统不起作用一样。
I can manually load the source from:
我可以从以下位置手动加载源:
c:\users\me\workspace\test1\test1.cc
c:\users\me\workspace\test1\test1.cc
and the debugger works, but the next time I start a new project, I have to do it again. How do you instruct the eclipse/cygwin combo to correctly find source code?
并且调试器可以工作,但是下次我开始一个新项目时,我必须再做一次。您如何指示 eclipse/cygwin 组合正确查找源代码?
Alternatively, is Mingw any easier? I have experienced similar problems with eclipse seeing that mingw is there, but build failing because it doesn't find the executable.
或者,Mingw 更容易吗?我在 eclipse 中遇到了类似的问题,看到 mingw 存在,但是构建失败,因为它没有找到可执行文件。
回答by ParthaM
Here is how I made it work.
这是我如何使它工作。
- I goto Window ==> Preferences ==> C/C++ ==> Debug ==> Source Lookup Path
- I Add a Path Mapping: Project Source
- On the left side I put the path that Cygwin expects, i.e. \home\MyName\projects and on the right side I put the Windows path, i.e. C:\cygwin\home\MyName\projects
- 我转到窗口 ==> 首选项 ==> C/C++ ==> 调试 ==> 源查找路径
- 我添加一个路径映射:项目源
- 在左侧我放置了 Cygwin 期望的路径,即 \home\MyName\projects,在右侧我放置了 Windows 路径,即 C:\cygwin\home\MyName\projects
Then when I debug it finds the source file fine.
然后当我调试它发现源文件很好。
回答by user3517051
Go to Windows->Preference->C/C++ -> Debug -> Source Lookup Path. Add following 'Path mapping'.
转至 Windows->Preference->C/C++ -> Debug -> Source Lookup Path。添加以下“路径映射”。
\cygdrive\c -> c:\
回答by Fooo
Although Above are given good answers but still it might not solve the problem sometimes phew!!!!
虽然上面给出了很好的答案,但有时它仍然可能无法解决问题,呸!!!!
Suppose you install Cygwin in C: but your eclipse workspace is in D: then there is a problem in your mounting
假设您在 C: 中安装 Cygwin,但您的 eclipse 工作区在 D: 中,那么您的安装就有问题
all you should do is, open the cygwing shell & type "mount" to get the following :
您应该做的就是打开 cygwing shell 并键入“mount”以获取以下内容:
Ritvika@Ashutosh ~
$ ls
Ritvika@Ashutosh ~
$ mount
C:/cygwin64/bin on /usr/bin type ntfs (binary,auto)
C:/cygwin64/lib on /usr/lib type ntfs (binary,auto)
C:/cygwin64 on / type ntfs (binary,auto)
C: on /cygdrive/c type ntfs (binary,posix=0,user,noumount,auto)
D: on /cygdrive/d type ntfs (binary,posix=0,user,noumount,auto)
Ritvika@Ashutosh ~
$
here my Projects are all under D:\ECWorkSpace, so my mapping needs to be present in Eclipse as: /cygdrive/d d:/
这里我的项目都在 D:\ECWorkSpace 下,所以我的映射需要在 Eclipse 中显示为:/cygdrive/dd:/
Hence, now Armed with this knowledge do what PathM says
因此,现在有了这些知识,就按照 PathM 所说的去做
1. goto Window ==> Preferences ==> C/C++ ==> Debug ==> Source Lookup Path
2. Add a Path Mapping: Project Source
3. On the left side put "cygdrive\d", & on the right put : "D:\"
This should work. ( It did for me :) ) You can Check this FAQ as well : https://wiki.eclipse.org/CDT/User/FAQ#I.27m_using_cygwin_and_when_launching_the_debugger.2C_it_complains_that_it_can.27t_find_the_source_file
这应该有效。(它对我有用:))您也可以查看此常见问题解答:https: //wiki.eclipse.org/CDT/User/FAQ#I.27m_using_cygwin_and_when_launching_the_debugger.2C_it_complains_that_it_can.27t_find_the_source_file
回答by Gauthier Boaglio
I use MinGW + CDT, and it is giving me great satisfaction. I installed it many times and never had any disagreement. No much to configure than what you did with cygwin. Download the Eclipse for C/C++ developers (probably what you did) to get CDT
(MinGW Tool Chain -> gdb + gcc) directly operational. Set your \\MinGW\bin\
directory into your PATH
and you should be good to go...
我使用MinGW + CDT,它让我非常满意。我安装了很多次,从未有过任何分歧。没有比你用 cygwin 所做的更多配置。为 C/C++ 开发人员下载 Eclipse(可能是你所做的)以CDT
直接运行(MinGW Tool Chain -> gdb + gcc)。将您的\\MinGW\bin\
目录设置为您的目录PATH
,您应该很高兴...
Note : Like Cygwin, MinGW provides a Linux-like Shell.
注意:与 Cygwin 一样,MinGW 提供了类似 Linux 的 Shell。
For MinGW-64, ready-made builds are a little bit more difficult to locate. See here.
对于 MinGW-64,现成的构建更难定位。见这里。
回答by hpjepsen
Look at set-up of "Common Source Lookup Path" here: http://wyding.blogspot.dk/2009/04/setup-cygwin-toolchain-in-eclipse-cdt.html
在此处查看“通用源查找路径”的设置:http: //wyding.blogspot.dk/2009/04/setup-cygwin-toolchain-in-eclipse-cdt.html