[英]How Do I Use Eclipse to Debug a C++ Program on Linux?
I don't use Eclipse as an IDE, and have no interest in doing so. 我不使用Eclipse作为IDE,并且没有兴趣这样做。 However, I do like its source-level debugging. 但是,我喜欢它的源代码级调试。
Is there any way I can use it to debug a C++ Linux app without going through the ritual of creating a project? 有没有什么方法可以用它来调试C ++ Linux应用程序而无需通过创建项目的仪式? (In effect, can I just use it like a frontend to gdb?) (实际上,我可以像使用gdb的前端一样使用它吗?)
If not, what are the steps I need to follow to create a project that I can use to just debug an existing C++ program that is built using Makefiles or other tools (SCons, CMake, etc.). 如果没有,我需要遵循什么步骤来创建一个项目,我可以用它来调试使用Makefile或其他工具(SCons,CMake等)构建的现有C ++程序。 I don't want to be able to "develop" in Eclipse; 我不想在Eclipse中“开发”; all I need to do is debug. 我需要做的就是调试。
Take a look at this question . 看看这个问题 。 Create a C/C++-project, use your project's source directory as project directory, select to use the external builder, and change "make" to whatever tool you want. 创建一个C / C ++项目,使用项目的源目录作为项目目录,选择使用外部构建器,并将“make”更改为您想要的任何工具。
The tricky part is to get the indexer to work correctly and find all your header files. 棘手的部分是让索引器正常工作并找到所有头文件。
EDIT: CMake 2.6.x has support for generating CDT project files, which might be a more straightforward solution. 编辑:CMake 2.6.x支持生成CDT项目文件,这可能是一个更直接的解决方案。
I don't know if this has changed in the 4+ years since the question was posted, but there's a much easier way to do this. 自问题发布以来的4年多时间里,我不知道这是否已经发生了变化,但是有一种更简单的方法可以做到这一点。 I'm on Eclipse Luna (4.4.2). 我在Eclipse Luna(4.4.2)上。
> eclipse&
then 然后
File
> Import
> C/C++
> C/C++ Executable
> Next
> browse to executable > Next
> choose a project name > Finish
File
> Import
> C/C++
> C/C++ Executable
> Next
>浏览到可执行文件> Next
>选择项目名称> Finish
No other project setup required, no source paths (which should be in the object code). 不需要其他项目设置,没有源路径(应该在目标代码中)。 Just like running gdb/insight/etc. 就像运行gdb / insight / etc一样。 Almost makes it worth installing Java. 几乎值得安装Java。
Configuration for debugging in Eclipse. 在Eclipse中进行调试的配置。
In eclipse, 在日食中,
Path Mapping:Project source and click on apply and then ok
. 在debug选项中,单击Source Lookup Path并选择Path Mapping:Project source and click on apply and then ok
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.