我正在使用CLion 2016.2.2,并且想调试libtins库中的方法。但是,似乎源不可用,因为尝试从libtins跳入方法时,调试器不会进入,只会更新当前 View 。

我尝试通过添加include_directories("/home/patrick/libtins/")include_directories("/home/patrick/libtins/src/")遵循this post中的建议,而libtins是从libtins存储库中克隆的根文件夹。但是CLion仍然找不到与libtins库关联的源文件。

我的CMake文件如下所示:

project(myproject)

# Define CMake settings
cmake_minimum_required(VERSION 3.2)

IF(NOT CMAKE_BUILD_TYPE)
   SET(CMAKE_BUILD_TYPE "Release")
ENDIF()

IF (CMAKE_BUILD_TYPE MATCHES Debug)
    MESSAGE(STATUS "Running Debug configuration.")
ELSEIF (CMAKE_BUILD_TYPE MATCHES Release)
    MESSAGE(STATUS "Running Release configuration.")
ENDIF()

SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall")

SET(CMAKE_CXX_STANDARD 11)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)

# Add the library source files
SET(SOURCE_FILES cxx/myclass.cpp cxx/myclass.h)

# Include SQLiteCpp library and build it
option(SQLITECPP_RUN_CPPLINT OFF)
include_directories(SQLiteCpp/include)
add_subdirectory(SQLiteCpp)

# Find libtins library
FIND_LIBRARY(TINS_LIBRARY tins)
IF(TINS_LIBRARY)
  MESSAGE(STATUS "Tins library found in ${TINS_LIBRARY}")
ELSE()
  MESSAGE(FATAL_ERROR "Tins library not found.")
ENDIF()

FIND_PACKAGE(PythonLibs 3.0 REQUIRED)
IF(PYTHONLIBS_FOUND)
  INCLUDE_DIRECTORIES("${PYTHON_INCLUDE_DIRS}")
ELSE()
  MESSAGE(FATAL_ERROR "Unable to find Python libraries.")
ENDIF()

# Find and configure BOOST library
FIND_PACKAGE(Boost 1.54 QUIET)
IF (Boost_FOUND)
    INCLUDE_DIRECTORIES("${Boost_INCLUDE_DIRS}")
    SET(Boost_USE_STATIC_LIBS OFF)
    SET(Boost_USE_MULTITHREADED ON)
    SET(Boost_USE_STATIC_RUNTIME OFF)
    # Find the boost python 3 component
    SET(PYTHON_VERSIONS python3 python-py35 python-py34 python-py33 python-py32)
    FOREACH(VERSION ${PYTHON_VERSIONS})
      FIND_PACKAGE(Boost COMPONENTS ${VERSION} QUIET)
      IF(Boost_FOUND)
        MESSAGE(STATUS "Python Boost found as '${VERSION}'.")
        BREAK()
      ENDIF()
    ENDFOREACH(VERSION)
    IF(NOT Boost_FOUND)
      MESSAGE(FATAL_ERROR "Python Boost component not found.")
    ENDIF()
ELSE ()
    MESSAGE(FATAL_ERROR "Unable to find the Boost libraries (version 1.54 or higher).")
ENDIF ()

SET_target_properties(sqlite3 PROPERTIES POSITION_INDEPENDENT_CODE ON)

ADD_EXECUTABLE(myproject ${SOURCE_FILES} "/home/pjattke/libtins/")
TARGET_LINK_LIBRARIES(myproject ${Boost_LIBRARIES} "${TINS_LIBRARY}" SQLiteCpp sqlite3 pthread dl)

为了使CLion源文件可用于调试,我到底需要更改什么?

最佳答案

如果libtins是在没有调试信息的情况下构建的,则可能会发生这种情况。您如何 build 它?

应该大致如下:

mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug ../
make

关于c++ - CLion:通过添加源文件启用外部库的调试,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40622244/

10-10 02:58