Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » Can't debug with CMake
Can't debug with CMake [message #1851725] Wed, 13 April 2022 16:25 Go to next message
Eclipse UserFriend
Hi!

I'm trying to create a new CMake project in order to do some tests with a library. After some coding, compiling and executing, it came the opportunity to try the debugger. At that point, I discovered that CMake projects created by Eclipse can't be debugged, they always result in a "No source available for "main() at..." message. Even the most basic "hello world" project can't accomplish that task.

I'm using Eclipse 2022.03 (4.23.0) on a Debian Bullseye system, cmake version 3.18.4.

Thanks in advance.

[Updated on: Thu, 14 April 2022 08:41] by Moderator

Re: Can't debug with CMake [message #1851847 is a reply to message #1851725] Tue, 19 April 2022 18:55 Go to previous messageGo to next message
Eclipse UserFriend
Please provide us contents of you CMake file script. Maybe, you've just forgotten to add the "-Og" option you your build configuration.
Re: Can't debug with CMake [message #1851857 is a reply to message #1851847] Wed, 20 April 2022 06:36 Go to previous messageGo to next message
Eclipse UserFriend
Even the Eclipse's CMake template project can't be debugged. Here's the file contents:

cmake_minimum_required (VERSION 2.6)

project (Teste_CMake_Debug)

add_executable(Teste_CMake_Debug Teste_CMake_Debug.cpp)


Concerning with the "-Og" option, how can I do that?
Re: Can't debug with CMake [message #1851862 is a reply to message #1851857] Wed, 20 April 2022 09:06 Go to previous messageGo to next message
Eclipse UserFriend
There are a few options to do that:
1) Use "add_compile_options" command. This is the approach I use. You may find a description here: https://cmake.org/cmake/help/latest/command/add_compile_options.html.
2) You may also use "add_definitions" command. It is not intended to be used to add compilation flags, but to add preprocessor definitions, so it might confuse other people. See this link: https://cmake.org/cmake/help/v3.0/command/add_definitions.html?highlight=s;
3) Finally, you may play with "CFLAGS" environment variable. Link: https://cmake.org/cmake/help/latest/envvar/CFLAGS.html
Re: Can't debug with CMake [message #1851869 is a reply to message #1851862] Wed, 20 April 2022 12:21 Go to previous messageGo to next message
Eclipse UserFriend
Just tried (1) and (2), but got the same problem.
Re: Can't debug with CMake [message #1851870 is a reply to message #1851869] Wed, 20 April 2022 12:30 Go to previous messageGo to next message
Eclipse UserFriend
The question is again nearly off-topic for Eclipse. Please Google for 'cmake debug'.
Re: Can't debug with CMake [message #1851882 is a reply to message #1851870] Wed, 20 April 2022 20:11 Go to previous messageGo to next message
Eclipse UserFriend
>>Tauno Voipio
Yep, but if it has been already posed why not to lend a hand?

>> Alexsander Oliveira
It's very difficult to figure out what's going on remotely. You should either present your complete CMakeLists.txt file, build logs and debugger settings. Or (and that is recommended) first put off CMake, and play a little with a native Eclipse project. Just use project wizard, write a little test project and peek how it behaves. Then check settings and compare them with ones you've put into your CMake script. Oh, and don't forget to peek GCC manual too. You must understand

[Updated on: Wed, 20 April 2022 20:11] by Moderator

Re: Can't debug with CMake [message #1851947 is a reply to message #1851882] Fri, 22 April 2022 09:35 Go to previous messageGo to next message
Eclipse UserFriend
Hi!

This what I'm trying to do, just using a project wizard to see how it behaves in debugging mode. That cmake file script was generate by Eclipse - I didn't touch it. Unfortunately, even this template project doesn't run in debug mode - although it can be executed in normal mode.
Re: Can't debug with CMake [message #1855652 is a reply to message #1851725] Tue, 25 October 2022 15:11 Go to previous messageGo to next message
Eclipse UserFriend
I got mine to debug by editing the Launch Configuration next to the debug/run drop down.
When you go to the Edit Configuration->Build Setting, set the Build Command to cmake -DCMAKE_BUILD_TYPE=Debug
Re: Can't debug with CMake [message #1856289 is a reply to message #1851857] Thu, 01 December 2022 06:55 Go to previous message
Eclipse UserFriend
I had to add
set(CMAKE_BUILD_TYPE Debug)

To my CMakeLists.txt
Previous Topic:Custom syntax/code highlight
Next Topic:Looking for a plug-in : HELP
Goto Forum:
  


Current Time: Wed Jul 23 15:43:27 EDT 2025

Powered by FUDForum. Page generated in 0.04346 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top