Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Can't debug with CMake
Can't debug with CMake [message #1851725] Wed, 13 April 2022 20:25 Go to next message
Alexsander Oliveira is currently offline Alexsander OliveiraFriend
Messages: 4
Registered: April 2022
Junior Member
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 12:41]

Report message to a moderator

Re: Can't debug with CMake [message #1851847 is a reply to message #1851725] Tue, 19 April 2022 22:55 Go to previous messageGo to next message
Gleb Plekhotko is currently offline Gleb PlekhotkoFriend
Messages: 5
Registered: April 2022
Junior Member
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 10:36 Go to previous messageGo to next message
Alexsander Oliveira is currently offline Alexsander OliveiraFriend
Messages: 4
Registered: April 2022
Junior Member
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 13:06 Go to previous messageGo to next message
Gleb Plekhotko is currently offline Gleb PlekhotkoFriend
Messages: 5
Registered: April 2022
Junior Member
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 16:21 Go to previous messageGo to next message
Alexsander Oliveira is currently offline Alexsander OliveiraFriend
Messages: 4
Registered: April 2022
Junior Member
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 16:30 Go to previous messageGo to next message
Tauno Voipio is currently offline Tauno VoipioFriend
Messages: 739
Registered: August 2014
Senior Member
The question is again nearly off-topic for Eclipse. Please Google for 'cmake debug'.


--

Tauno Voipio
Re: Can't debug with CMake [message #1851882 is a reply to message #1851870] Thu, 21 April 2022 00:11 Go to previous messageGo to next message
Gleb Plekhotko is currently offline Gleb PlekhotkoFriend
Messages: 5
Registered: April 2022
Junior Member
>>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: Thu, 21 April 2022 00:11]

Report message to a moderator

Re: Can't debug with CMake [message #1851947 is a reply to message #1851882] Fri, 22 April 2022 13:35 Go to previous messageGo to next message
Alexsander Oliveira is currently offline Alexsander OliveiraFriend
Messages: 4
Registered: April 2022
Junior Member
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 19:11 Go to previous messageGo to next message
Lawrence Lewis is currently offline Lawrence LewisFriend
Messages: 1
Registered: October 2022
Junior Member
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 11:55 Go to previous message
Eoin Dowling is currently offline Eoin DowlingFriend
Messages: 1
Registered: December 2022
Junior Member
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: Mon Jan 30 18:12:22 GMT 2023

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

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

Back to the top