Mac C++/eclipse 无法调试:启动命令时出错:gdb --version
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21082234/
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
Mac C++/eclipse cannot debug: Error while launching command: gdb --version
提问by user3000888
I am using c++/eclipse kepler on mac, and I cannot debug any project. The error is "Error while launching command: gdb --version" Besides that, I can build and run my code using other libraries.
我在 mac 上使用 c++/eclipse kepler,我无法调试任何项目。错误是“启动命令时出错:gdb --version”除此之外,我可以使用其他库构建和运行我的代码。
I searched a site that is similar to my problem: Debugger for C++ eclipse gives the following error. 'Launching program name' has encountered a ... Error while launching command: gdb --version
我搜索了一个与我的问题类似的站点:C++ eclipse 调试器给出了以下错误。“启动程序名称”遇到...启动命令时出错:gdb --version
But what should I change if I am using a mac?
但是如果我使用的是 mac,我应该改变什么?
回答by Neil Traft
You can fix this by specifying the full path to gdb. You can do this separately for each debug configuration, and you can also set the default gdb location in the preferences under C/C++ > GDB. For example, if you installed gdb via Homebrew, then it's probably located under /usr/local/bin
:
您可以通过指定 gdb 的完整路径来解决此问题。您可以为每个调试配置单独执行此操作,也可以在C/C++ > GDB下的首选项中设置默认 gdb 位置。例如,如果您通过 Homebrew 安装了 gdb,那么它可能位于/usr/local/bin
:
And here's a screenshot of the Preferences:
这是首选项的屏幕截图:
I still don't know why Eclipse can't find GDB even though it is on my path. I guess it doesn't use my .bash_profile
or my .bashrc
? You could try symlinking gdb into /usr/bin
. Maybe Eclipse will look there.
我仍然不知道为什么 Eclipse 即使在我的路径上也找不到 GDB。我猜它不使用 my.bash_profile
或 my .bashrc
? 您可以尝试将 gdb 符号链接到/usr/bin
. 也许 Eclipse 会去那里看看。
Edit:I tried the symbolic link idea and now Eclipse can debug, but it crashes inexplicably while doing so! So, I guess... don'tdo that?
编辑:我尝试了符号链接的想法,现在 Eclipse 可以调试了,但是这样做时它莫名其妙地崩溃了!所以,我想……不要那样做?
回答by Chris Hawk
This guide from a UC Irvine Computer Science professor's page is a very well-written, detailed, and Mac-specfic description of all the steps involved in installing GDB, creating a certificate, signing GDB using that certificate, and finally configuring Eclipse. I was found this very helpful as someone unfamiliar with each of these steps.
本指南来自加州大学欧文分校计算机科学教授的页面,它对安装 GDB、创建证书、使用该证书签署 GDB 以及最终配置 Eclipse 所涉及的所有步骤进行了精心编写、详细且 Mac 特定的描述。作为一个不熟悉这些步骤的人,我发现这非常有帮助。
回答by kishore .
I had the same problem. I solved it by:
我有同样的问题。我通过以下方式解决了它:
- Install a gdb - ( I used 7.8.1) - compile and install it. It got installed in
usr/local/bin
- Codesigning certificate
- Open eclipse executable using
sudo
. Otherwise I still get the error.
- 安装一个 gdb -(我用的是 7.8.1) - 编译并安装它。它安装在
usr/local/bin
- 协同设计证书
- 使用
sudo
. 否则我仍然收到错误。
I am on OS X. Hope this helps.
我在 OS X 上。希望这会有所帮助。
回答by Arnout
I had this error too now, and spent more than an hour looking for it. In my case, the path was correct, and eclipse seemed to fail to start "any" executable as debugger. (I tested with gksudo cat, but it clearly never got to effectively running it).
我现在也有这个错误,花了一个多小时寻找它。就我而言,路径是正确的,eclipse 似乎无法将“任何”可执行文件作为调试器启动。(我用 gksudo cat 进行了测试,但它显然从未有效地运行它)。
The final reason was that I had put in my eclipse.ini -Xms1G and -Xmx1G.It seemed to already use the full memory for the indexer, and trying to allocate some more memory to start the debugger failed with an "unkown" error. Removing the memory limitations fixed the issue.
最后一个原因是我已经放入了我的 eclipse.ini -Xms1G 和 -Xmx1G。它似乎已经为索引器使用了全部内存,并且尝试分配更多内存以启动调试器失败,并出现“未知”错误。删除内存限制解决了这个问题。
Hope this helps someone
希望这有助于某人
回答by Carlos Ballock
I had many difficulties making GDB to work on Eclipse. I tried LLDB instead and it worked like a charm:
我在使 GDB 在 Eclipse 上工作时遇到了很多困难。我尝试了 LLDB,它的作用就像一个魅力:
https://wiki.eclipse.org/CDT/User/FAQ#How_do_I_get_the_LLDB_debugger.3F
https://wiki.eclipse.org/CDT/User/FAQ#How_do_I_get_the_LLDB_debugger.3F
This can be a more convenient alternative for Mac users.
对于 Mac 用户来说,这可能是一个更方便的选择。
回答by Sergej Fomin
Mac OS Sierra 10.13.6 gdb 8.0.1
Mac OS Sierra 10.13.6 gdb 8.0.1
had the same error as topic-starter.
与 topic-starter 有相同的错误。
first, I set the path as Neil Traft (here in the answers) explains to usr/local/bin/gdb;
首先,我将路径设置为 Neil Traft(在答案中)向 usr/local/bin/gdb 解释的路径;
But it didn't work.
但它没有用。
I found these instructions: https://gist.github.com/gravitylow/fb595186ce6068537a6e9da6d8b5b96d
我找到了这些说明:https: //gist.github.com/gravitylow/fb595186ce6068537a6e9da6d8b5b96d
and I discovered that I already had gdbcert1 in my System. So I followed everything from 7. Works!
我发现我的系统中已经有了 gdbcert1。所以我遵循了 7 的所有内容。有效!