简体   繁体   English

使用Eclipse调试C ++库

[英]Debugging C++ lib with eclipse

I am working on project in Linux which involves 1) Static Lib in C++ 2) GUI developed in C++/QT which uses static lib. 我正在Linux中从事项目,涉及1)C ++中的静态库2)C ++ / QT中使用静态库开发的GUI。

Now both the lib and gui are build from command prompt using makefiles. 现在,lib和gui都是使用makefile从命令提示符处构建的。

I am trying to debug both like when I hit one button, call should go from GUI to lib. 我试图调试两者,就像我按一个按钮一样,调用应该从GUI转到lib。

Is it possible to do like this in Linux with eclipse? 是否可以在带有eclipse的Linux中这样做? I can easily follow same debugging procedure in Windows using Visual studio and attaching lib to GUI but I cannot find any good way to do here with eclipse. 我可以使用Visual Studio在Windows中轻松地执行相同的调试过程,并将lib附加到GUI,但是在Eclipse中我找不到任何好的方法。

I have tried many IDEs/debuggers like Anjuta Code Blocks. 我尝试了许多IDE /调试器,例如Anjuta代码块。 DDD,Kdbg but none is working properly. DDD,Kdbg,但没有一个正常工作。

I am not sure that if I am wrong or is it much complex to debug? 我不确定如果我做错了或者调试起来是否很复杂?

Can some one suggest one proper way to debug ? 有人可以建议一种适当的调试方法吗?

There shouldn't be any problem with debugging a static library as the relevant portions of it will be built in to the binary that you are debugging. 调试静态库应该没有任何问题,因为静态库的相关部分将内置到您要调试的二进制文件中。 If you are having problems then some things to check are that both the library and the binary are built with debugging information (usually the option -g to the compiler on linux) and that your debugger has access to the source code to the library. 如果遇到问题,则需要检查的一点是,库和二进制文件都是使用调试信息构建的(通常是Linux上的编译器选项-g ),并且调试器可以访问库的源代码。

Can you be any more specific about how debugging isn't working? 您能否更详细地说明调试是如何工作的? It sounds like 'stepping in' to a library function isn't working as you are expecting it to. 听起来像“步入”库功能无法正常工作。

Well I figured it out.. I am currently using Kdevelop.. With Kdevelp we can create QT project as well as c++(lib) project. 好吧,我弄清楚了..我目前正在使用Kdevelop ..使用Kdevelp,我们可以创建QT项目以及c ++(lib)项目。 And there is option to attach process also. 并且还有附加流程的选项。 So I can step through lib code by attaching GUI . 因此,我可以通过附加GUI来逐步检查lib代码。

I created new project in eclipse and added existing source folder . 我在eclipse中创建了新项目,并添加了现有的source文件夹。 It then automatically adds all source files. 然后,它将自动添加所有源文件。 Project has its own custom makefile . 项目具有自己的自定义makefile。 Now when I try to Debug the project , it shows me Debug window where I selected C/C++ Attach to Local application because I want to attach lib to GUI. 现在,当我尝试调试项目时,它显示了“调试”窗口,在该窗口中选择了“ C / C ++附加到本地”应用程序,因为我想将lib附加到GUI。

It asks me to enter project name in Debug window. 它要求我在“调试”窗口中输入项目名称。

In Windows with visual studio it gives list of processes that can be attached, but here am I supposed to create project ? 在带有Visual Studio的Windows中,它提供了可以附加的进程列表,但是我应该在这里创建项目吗?

I dont understand this.. 我不明白这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM