简体   繁体   English

CLION -- 如何为 CMakeLists.txt 文件中未提及的应用程序创建和调试配置

[英]CLION -- How to create and debug a configuration for an application not mentioned in the CMakeLists.txt file

  1. How can I configure CLion to debug an executable not referenced in a CMakelLists.txt file?如何配置 CLion 以调试 CMakelLists.txt 文件中未引用的可执行文件? OR或者
  2. How can I configure CLion to debug an executable created using the Makefile plugin?如何配置 CLion 以调试使用 Makefile 插件创建的可执行文件?

在此处输入图片说明

I am working with CLion 18.2.3 without a CMakeLists.txt file.我正在使用没有 CMakeLists.txt 文件的 CLion 18.2.3。 I created a configuration from the Application template and named the configuration “Execute”.我从应用程序模板创建了一个配置,并将该配置命名为“执行”。 In the Execute configuration, I specify the executable (main) and the target as All targets.在 Execute 配置中,我将可执行文件 (main) 和目标指定为所有目标。 The executable exists (having been built earlier using the Makefile Plugin).可执行文件存在(之前已使用 Makefile 插件构建)。

When I attempt to debug or run the Execute configuration, Clion reports,当我尝试调试或运行执行配置时,Clion 报告,

Error running Execute: Cannot run Execute on <default>.

I am not sure how to get CLion to debug an executable that is in the project directory that is not referenced in a CMakeLists.txt file.我不确定如何让 CLion 调试项目目录中未在 CMakeLists.txt 文件中引用的可执行文件。

I have a large project which uses the Makefile plugin.我有一个使用 Makefile 插件的大型项目。 This compiles the desired executable beautifully.这可以很好地编译所需的可执行文件。 However, I am not able to debug the executable, set breakpoints, or otherwise use debugging with the executable.但是,我无法调试可执行文件、设置断点或以其他方式对可执行文件进行调试。 I have run this on Ubuntu 18.04 and on Mac OSX High Sierra.我已经在 Ubuntu 18.04 和 Mac OSX High Sierra 上运行了它。

So, either 1. How can I configure CLion to debug an executable not referenced in a CMakelLists.txt file?那么,要么 1. 如何配置 CLion 以调试未在 CMakelLists.txt 文件中引用的可执行文件? OR 2. How can I configure CLion to debug an executable created using the Makefile plugin?或 2. 如何配置 CLion 以调试使用 Makefile 插件创建的可执行文件? Thank you, John谢谢你,约翰

Here is a copy of the configuration that is being run:这是正在运行的配置的副本:

在此处输入图片说明

The first image shows the output when this configuration is run, "Error running'Execute': Cannot run 'Execute' on ''"第一个图像显示了运行此配置时的输出,“错误运行‘执行’:无法在‘’上运行‘执行’”

If you open the drop down menu in the top right of clion and click edit configuration you are able to create custom configurations.如果您打开 clion 右上角的下拉菜单并单击编辑配置,您就可以创建自定义配置。 There you can add the executable and parameters if required.如果需要,您可以在那里添加可执行文件和参数。 Now you should be able to run and also debug this executable.现在您应该能够运行并调试这个可执行文件。

Another option is to run the executable and attach the debugger over the menu entry run->attach to local process (Ctrl+Alt+5) and then select you executable.另一种选择是运行可执行文件并将调试器附加到菜单项run->attach to local process (Ctrl+Alt+5) 上,然后选择您的可执行文件。

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

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