Ich verwende CLion 2016.2.2 und ich möchte eine Methode in der libtins-Bibliothek debuggen. Es sieht jedoch so aus, als ob die Quellen nicht verfügbar sind, da der Debugger beim Versuch, in die Methoden von libtins zu springen, nicht in die aktuelle Ansicht wechselt und nur die aktuelle Ansicht aktualisiert.CLion: Debuggen von externen Bibliotheken durch Hinzufügen von Quelldateien aktivieren
Ich versuchte, dem Vorschlag in this post zu folgen, indem ich include_directories("/home/patrick/libtins/")
oder include_directories("/home/patrick/libtins/src/")
hinzufüge, während libtins der Stammordner ist, der vom libtins-Speicherorton geklont wird. Aber CLion konnte die mit der libtins-Bibliothek verknüpften Quelldateien immer noch nicht finden.
Meine CMake-Datei sieht wie folgt:
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)
Was genau muss ich ändern CLION die Quelldateien für das Debuggen zu machen?
Ernsthaft? Die UL-zugelassene Lösung für das Debugging in externe Bibliotheken (mit installierten Debug-Informationen) besteht darin, die Bibliothek als Teil Ihres Projekts zu erstellen? Ich würde es kaum so einfach nennen. Ich habe auch dieses Problem mit CLion - ich habe festgestellt, dass, selbst wenn gdb die Bibliotheksquellen finden kann, CLion das immer noch nicht kann. –
@JohnCalcote Wenn Sie die Bibliothek als Teil Ihres Projekts erstellen, stellen Sie sicher, dass Sie dieselben Kompilierungsflags wie die anderen Teile Ihres Projekts haben (hier Debug). Also, ja, CLion wird es finden, und, ja, ich würde das so einfach nennen. Sie können sich nicht darauf verlassen, dass die Debug-Informationen in jedem Fall installiert werden. – oLen
@ JohnCalcote ist 100% richtig. In den meisten Fällen ist es verrückt zu empfehlen, einen externen Build komplett neu zu erstellen. Die meisten Projekte haben extrem komplexe Build-Systeme, was darauf hindeutet, dass Sie es einfach in Ihr eigenes Build-System einfügen, ist nicht realistisch. –