Gardener
Gardener

Reputation: 2660

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? OR
  2. How can I configure CLion to debug an executable created using the Makefile plugin?

enter image description here

I am working with CLion 18.2.3 without a CMakeLists.txt file. 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. The executable exists (having been built earlier using the Makefile Plugin).

When I attempt to debug or run the Execute configuration, Clion reports,

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.

I have a large project which uses the Makefile plugin. 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.

So, either 1. How can I configure CLion to debug an executable not referenced in a CMakelLists.txt file? OR 2. How can I configure CLion to debug an executable created using the Makefile plugin? Thank you, John

Here is a copy of the configuration that is being run:

enter image description here

The first image shows the output when this configuration is run, "Error running'Execute': Cannot run 'Execute' on ''"

Upvotes: 3

Views: 6696

Answers (1)

FreshD
FreshD

Reputation: 3112

If you open the drop down menu in the top right of clion and click edit configuration you are able to create custom configurations. 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.

Upvotes: 3

Related Questions