2016-12-01 323 views
1

我想知道字符串是如何工作的,所以我在basic_string.h中添加了断点。 但是当我调试时它并没有进入这些断点。Clion debug:如何进入STL

当我在调试时添加断点时,GDB控制台显示: 文件“C:/Users/manch/Downloads/MinGW/lib/gcc/mingw32/4.8.1/include/C++/bits”中没有行1008 /basic_string.h”。

enter image description here

这是我的测试代码

#include <iostream> 
#include <string> 

int main() { 
    std::string *ps = new std::string("hello"); 
    ps->append(" world"); 
    return 0; 
} 

和的CMakeLists.txt

cmake_minimum_required(VERSION 3.6) 
project(Stl) 

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 

set(SOURCE_FILES main.cpp test.cpp C:/Users/manch/Downloads/MinGW/lib/gcc/mingw32/4.8.1/include/c++/bits/stl_construct_copy.h) 
add_executable(Stl ${SOURCE_FILES}) 

回答

0

您还需要有源文件libstdc++标准C++库MinGW的链接您的可执行文件。然后,根据this的问题,您需要在编译时添加-D_GLIBCXX_DEBUG标志,以便连接具有调试信息的库。