Embedded Cling partially working


Hi, I’ve been interested on using ROOT Cling as part of a project that reads external *.cpp files to expand itself, however I ran into multiple hurdles trying to properly setup a working demo.

my current setup consist of the standalone build of Cling alongside the LLVM/Clang used to build against, I went with this options due to some issues I had with the Cling+LLVM build with missing install files. I managed to reach a point where Cling partially works but fails at finding RuntimeUniverse.h and breaks when trying to include libraries.

I tried bashing my head onto it alongside using help from Claude to no avail, so I welcome any help possible :slight_smile:.

below is my current CmakeLists.txt :

project(cling_test C CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(LLVM_NO_DEAD_STRIP 1)

add_executable(cling_test main.cpp)

set(Cling_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third-party/cling-install/lib/cmake/cling/")
set(LLVM_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third-party/llvm-install/lib/cmake/llvm/")
set(Clang_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third-party/llvm-install/lib/cmake/clang/")

find_package(LLVM REQUIRED)
find_package(Clang REQUIRED)
find_package(Cling REQUIRED)

target_include_directories(cling_test PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/third-party/cling-install/include/"
"${CMAKE_CURRENT_SOURCE_DIR}/third-party/llvm-install/include/"
)
target_link_libraries(cling_test "${CMAKE_CURRENT_SOURCE_DIR}/third-party/cling-build/lib/libcling.so")

target_compile_options(cling_test PUBLIC -DLLVMDIR="${CMAKE_CURRENT_SOURCE_DIR}/third-party/llvm-install" -I$${CMAKE_CURRENT_SOURCE_DIR}/third-party/llvm-install/include -I$${CMAKE_CURRENT_SOURCE_DIR}/third-party/cling-install/include)
target_compile_options(cling_test PRIVATE -fno-rtti)
set_target_properties(cling_test PROPERTIES ENABLE_EXPORTS 1)

ROOT Version: 6.40.04
Platform: Arch
Compiler: gcc