使用cmake时未创建调试符号

Use*_*232 7 c++ gdb cmake

我在添加后使用cmake 在github.com/RainerKuemmerle/g2o编译了c ++代码库

set(CMAKE_BUILD_TYPE Debug)
Run Code Online (Sandbox Code Playgroud)

以便能够调试应用程序.然后它创建了一个名为"g2o"的构建文件.但是当我尝试使用gdb进行调试时,这是我得到的输出.

user2@arm_machine:~/g2o/trunk/bin$ gdb g2o
GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "arm-linux-gnueabihf".
For bug reporting instructions, please see:
<http://bugs.launchpad.net/gdb-linaro/>...
Reading symbols from /scratch/mbaxkms7/ARM_Programs_mbaxkms7/g2o/trunk/bin/g2o...(no debugging symbols found)...done.
(gdb)
Run Code Online (Sandbox Code Playgroud)

有没有其他方法可以在使用cmake时生成调试信息?

Glu*_*ton 4

您的添加方法set(CMAKE_BUILD_TYPE Debug)效果很好。

但这g2o是用选项构建的程序ReleaseDebug的版本g2o称为g2o_d. 因此,要进行调试,您需要按以下方式启动调试器:

user2@arm_machine:~/g2o/trunk/bin$ gdb g2o_d
Run Code Online (Sandbox Code Playgroud)

注意
不同的名称不是项目的共同特征,而是项目CMake的共同特征:g2o

# postfix, based on type
SET(CMAKE_DEBUG_POSTFIX "_d" CACHE STRING "postfix applied to debug build of libraries")
SET(CMAKE_RELEASE_POSTFIX "" CACHE STRING "postfix applied to release build of libraries")
Run Code Online (Sandbox Code Playgroud)