[GNC-dev] debug info

John Ralls jralls at ceridwen.us
Sat Dec 15 11:19:51 EST 2018



> On Dec 15, 2018, at 6:16 AM, c.holtermann at gmx.de wrote:
> 
> Hello,
> 
> when debugging for my recent pull request #439 I needed to use
> gdb. When compiling the maint branch from github I didn't have debug
> information (line numbers) in gdb. I needed to add them by including
> the -g flag in CMakelLists.txt. I did it only for c and not for c++.
> Patch below for illustrative purposes.
> 
> Wouldn't it be good to have a command line option or environment
> variable to enable that debug information for c and c++ ?

Christoph,

Of course. That’s why Cmake provides CMAKE_BUILD_TYPE. To make a debug build, add the argument -D CMAKE_BUILD_TYPE=Debug to your cmake invocation.

BTW, the flags passed to the compilers are also modifiable from the command line using CMAKE_C_FLAGS and CMAKE_CXX_FLAGS. No need to change CMakeLists.txt.

Should you ever need to do this for an autotools project the equivalents are the environment variables CFLAGS and CXXFLAGS; autotools also reads CPPFLAGS and applies the contents to both c and c++ compiles. Autotools unfortunately doesn’t have an equivalent to CMAKE_BUILD_TYPE so you have to adjust the compiler flags.

Regards,
John Ralls



More information about the gnucash-devel mailing list