# Debug arbitrary executables

You can use CLion to debug an executable that was built elsewhere using any build system. This article describes three options you can choose between depending on your application. Whichever one you use, all the CLion debugging facilities will be fully available for your code. The requirements are that your binary includes debug symbols and you have the source files on hand.

## Option 1: Attach to a running process

The quickest solution is to attach the debugger to an already running process. This is suitable for applications that can run indefinitely, like various services.

> **Tip:**
> See [Attach to process](attach-to-process.html) for general information.

Procedure:

1. Select `File | Open` from the main menu and open the source files.

2. Set [breakpoints](using-breakpoints.html) and make sure they are going to be hit after you attach to the process.

3. Launch the process. You can do that outside the IDE or using the [built-in terminal](terminal-emulator.html) (`View | Tool Windows | Terminal` or `Alt+F12` (Windows), `⌥ F12` (macOS), `⌥ F12` (IntelliJ IDEA Classic (macOS)), `⌘ ⌃ T` (macOS System Shortcuts), `Alt+F12` (XWin), `Alt+F12` (GNOME), `Alt+F12` (KDE), `Alt+F12` (Emacs), `Alt+F12` (Sublime Text), `⌥ F12` (Sublime Text (macOS)), `⌥ F12` (Xcode), `Ctrl+Alt+1` (Visual Studio), `⌘ ⌃ 1` (Visual Studio (macOS)), `Ctrl+Alt+1` (ReSharper), `⌘ ⌃ 1` (ReSharper (macOS)), `Alt+F12` (QtCreator), `⌥ F12` (QtCreator (macOS)), `Alt+F12` (NetBeans), `Alt+F12` (Eclipse), `⌥ F12` (Eclipse (macOS))).

4. In CLion, call Run | Attach to Process from the main menu or press `Ctrl+Alt+F5` (Windows), `⌥ ⇧ F5` (macOS), `⌥ ⇧ F5` (IntelliJ IDEA Classic (macOS)), `⌥ ⇧ F5` (macOS System Shortcuts), `Ctrl+Alt+5` (XWin), `Ctrl+Alt+5` (GNOME), `Ctrl+Alt+5` (KDE), `Ctrl+Alt+F5` (Emacs), `Ctrl+Alt+F5` (Sublime Text), `⌥ ⇧ F5` (Sublime Text (macOS)), `⌥ ⇧ F5` (Xcode), `Ctrl+Alt+P` (Visual Studio), `⌘ ⌥ P` (Visual Studio (macOS)), `Ctrl+Alt+F5` (ReSharper), `⌃ ⌥ F5` (ReSharper (macOS)), `Ctrl+Alt+F5` (QtCreator), `⌥ ⇧ F5` (QtCreator (macOS)), `Ctrl+Alt+F5` (NetBeans), `Ctrl+Alt+F5` (Eclipse), `⌥ ⇧ F5` (Eclipse (macOS)).

5. In the list of entries, search for your process:

![Attaching to a running process](https://resources.jetbrains.com/help/img/idea/2026.2/cl_debug_exteranlexe_attach.png)

6. After the debugger is attached successfully, you will be able to debug as usual. For more information, refer to the [Debugging](debugging-code.html) section.

![Debugging a running process](https://resources.jetbrains.com/help/img/idea/2026.2/cl_debug_externalexe_attached.png)

7. When finished, call `Run | Stop` or click ![Suspend](https://resources.jetbrains.com/help/img/idea/2026.2/app.actions.suspend.svg) on the toolbar or in the [Debug tool window](debug-tool-window.html) to detach from the process.

## Option 2: Debug a fake CMake project

Another option is to create a basic CMake project and use a [CMake Application](run-debug-configuration-application.html) configuration for debugging an external executable.

Procedure:

1. Click New Project on the [Welcome screen](welcome-screen.html) or select `File | New Project` from the main menu.

2. Select any of the C/C++ templates, specify the project's name, and click Create.

![Creating a fake CMake project](https://resources.jetbrains.com/help/img/idea/2026.2/cl_debug_externalexe_fakeprj.png)

3. CLion will generate a stub project with a default run/debug configuration. You can use that configuration or create a new one from the CMake Application template.

![Default CMake configuration](https://resources.jetbrains.com/help/img/idea/2026.2/cl_debug_externalexe_fakeprj_config.png)

4. Go to `Run | Edit Configurations`. In the configuration settings, set the path the your executable:

![Setting a custom executable in the CMake configuration](https://resources.jetbrains.com/help/img/idea/2026.2/cl_debug_externalexe_fakeprj_config_exe.png)

Apply the settings.

5. Open the binary's sources using `File | Open` from the main menu.

> **Note:**
> You don't need to copy the sources into your project folder.

6. Navigate through the sources and set [breakpoints](using-breakpoints.html).

![Breakpoints in external sources](https://resources.jetbrains.com/help/img/idea/2026.2/cl_debug_externalexe_fakeprj_breakpoints.png)

CLion will show warnings that the files don't belong to the project. Since you are not using CMake as a build system, you can safely ignore these warnings.

7. When ready, start a debug session for the configuration you set up on step 4.

![Debugging an external executable from a fake CMake project](https://resources.jetbrains.com/help/img/idea/2026.2/cl_debug_externalexe_fakeprj_debugging.png)

> **Tip:**
> If required, you can [switch between the available debuggers](configuring-debugger-options.html#select-debugger) in the project's toolchain settings.

## Option 3: Debug a custom build application

As a more full-fledged alternative, employ CLion's [custom build targets](custom-build-targets.html) - a way to set up building and running/debugging for various kinds of C/C++ applications. You can configure [debugging](#custom-app) or a [complete chain](#custom-target) of build, clean, and debug.

Procedure: Create a custom configuration for debug

1. Open the source files in CLion using `File | Open` from the main menu.

2. Navigate through the sources and set [breakpoints](using-breakpoints.html).

3. In the main menu, go to `Run | Edit Configurations`, click ![](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.add.svg) and choose [Custom Build Application](custom-build-application.html) from the list of templates.

4. First, you need to specify a build target even if no actual build will be performed. This is required because the build target defines the toolchain from which the debugger is taken.

Click Configure custom build targets. In the dialog that opens, click ![](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.add.svg) to add a new target. Specify the target's name and leave the other fields empty:

![Creating a fake custom build target](https://resources.jetbrains.com/help/img/idea/2026.2/cl_debug_externalexe_customtarget_fake.png)

> **Note:**
> If you want CLion to perform build/clean for you, configure a proper build target as described [below](#custom-target).

Save the target and get back to the configuration settings.

5. * Select the created build target in the Target field. CLion will show a warning at the bottom of the Edit Configurations dialog. For debugging purposes, this warning can be ignored.

* Specify the application binary in the Executable field.

![Custom run/debug configuration](https://resources.jetbrains.com/help/img/idea/2026.2/cl_debug_externalexe_customconfig.png)

6. Save the configuration and start a debug session:

![Debugging a custom build application](https://resources.jetbrains.com/help/img/idea/2026.2/cl_debug_externalexe_customconfig_debug.png)

Procedure: Configure a custom build target (additionally)

In addition to a custom configuration for debugging, you can also set up the build/clean tools for your project.

We will take the Meson build system as an example.

1. Go to `Settings | Build, Execution, Deployment | Custom Build Targets` and click ![](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.add.svg) to add a new target.

2. Set up the build/clean tools. Make sure to specify the proper Working directory.

In our example, the Build tool is named Meson_build, and it calls `meson compile` in the `buildir` directory:

![Custom build tool](https://resources.jetbrains.com/help/img/idea/2026.2/cl_debug_externalexe_custombuildtool.png)

> **Tip:**
> After saving the target, you can start using the Build Project / Rebuild Project actions.

3. Go to `Run | Edit Configurations` and select the newly created custom target in the Target field:

![Custom configuration with build](https://resources.jetbrains.com/help/img/idea/2026.2/cl_debug_externalexe_custombuild_config.png)

4. Now if you debug this configuration, your project will be built using the specified tools first.

## See also

### How tos

[Custom build targets and applications](custom-build-targets.html) [Compilation database projects](compilation-database.html)

### Procedures

[Debugging](debugging-code.html) [Debugger options](configuring-debugger-options.html) [Attaching to a process](attach-to-process.html)

