Dear Experts,
When I use CMake to compile a C++ program which uses ROOT libraries, it gives me the error.
The root starts without any error message before I do anything with the CMakeLists.txt.
However, after I run CMake to compile, it gives me the following error message when I try to start root:
user@user-desktop:~/Research/lemuon_DC-2024February$ root
------------------------------------------------------------------
| Welcome to ROOT 6.30/04 https://root.cern |
| (c) 1995-2024, The ROOT Team; conception: R. Brun, F. Rademakers |
| Built for linuxx8664gcc on Jan 31 2024, 10:01:37 |
| From heads/master@tags/v6-30-04 |
| With c++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 |
| Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q' |
------------------------------------------------------------------
Error in <TUnixSystem::FindDynamicLibrary>: src/build/lemuonsuperlibrary[.so | .dll | .dylib | .sl | .dl | .a] does not exist in /opt/root/lib:.:/opt/root/lib:/lib/x86_64-linux-gnu/glibc-hwcaps/x86-64-v4:/lib/x86_64-linux-gnu/glibc-hwcaps/x86-64-v3:/lib/x86_64-linux-gnu/glibc-hwcaps/x86-64-v2:/lib/x86_64-linux-gnu/tls/haswell/avx512_1/x86_64:/lib/x86_64-linux-gnu/tls/haswell/avx512_1:/lib/x86_64-linux-gnu/tls/haswell/x86_64:/lib/x86_64-linux-gnu/tls/haswell:/lib/x86_64-linux-gnu/tls/avx512_1/x86_64:/lib/x86_64-linux-gnu/tls/avx512_1:/lib/x86_64-linux-gnu/tls/x86_64:/lib/x86_64-linux-gnu/tls:/lib/x86_64-linux-gnu/haswell/avx512_1/x86_64:/lib/x86_64-linux-gnu/haswell/avx512_1:/lib/x86_64-linux-gnu/haswell/x86_64:/lib/x86_64-linux-gnu/haswell:/lib/x86_64-linux-gnu/avx512_1/x86_64:/lib/x86_64-linux-gnu/avx512_1:/lib/x86_64-linux-gnu/x86_64:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu/glibc-hwcaps/x86-64-v4:/usr/lib/x86_64-linux-gnu/glibc-hwcaps/x86-64-v3:/usr/lib/x86_64-linux-gnu/glibc-hwcaps/x86-64-v2:/usr/lib/x86_64-linux-gnu/tls/haswell/avx512_1/x86_64:/usr/lib/x86_64-linux-gnu/tls/haswell/avx512_1:/usr/lib/x86_64-linux-gnu/tls/haswell/x86_64:/usr/lib/x86_64-linux-gnu/tls/haswell:/usr/lib/x86_64-linux-gnu/tls/avx512_1/x86_64:/usr/lib/x86_64-linux-gnu/tls/avx512_1:/usr/lib/x86_64-linux-gnu/tls/x86_64:/usr/lib/x86_64-linux-gnu/tls:/usr/lib/x86_64-linux-gnu/haswell/avx512_1/x86_64:/usr/lib/x86_64-linux-gnu/haswell/avx512_1:/usr/lib/x86_64-linux-gnu/haswell/x86_64:/usr/lib/x86_64-linux-gnu/haswell:/usr/lib/x86_64-linux-gnu/avx512_1/x86_64:/usr/lib/x86_64-linux-gnu/avx512_1:/usr/lib/x86_64-linux-gnu/x86_64:/usr/lib/x86_64-linux-gnu:/lib/glibc-hwcaps/x86-64-v4:/lib/glibc-hwcaps/x86-64-v3:/lib/glibc-hwcaps/x86-64-v2:/lib/tls/haswell/avx512_1/x86_64:/lib/tls/haswell/avx512_1:/lib/tls/haswell/x86_64:/lib/tls/haswell:/lib/tls/avx512_1/x86_64:/lib/tls/avx512_1:/lib/tls/x86_64:/lib/tls:/lib/haswell/avx512_1/x86_64:/lib/haswell/avx512_1:/lib/haswell/x86_64:/lib/haswell:/lib/avx512_1/x86_64:/lib/avx512_1:/lib/x86_64:/lib:/usr/lib/glibc-hwcaps/x86-64-v4:/usr/lib/glibc-hwcaps/x86-64-v3:/usr/lib/glibc-hwcaps/x86-64-v2:/usr/lib/tls/haswell/avx512_1/x86_64:/usr/lib/tls/haswell/avx512_1:/usr/lib/tls/haswell/x86_64:/usr/lib/tls/haswell:/usr/lib/tls/avx512_1/x86_64:/usr/lib/tls/avx512_1:/usr/lib/tls/x86_64:/usr/lib/tls:/usr/lib/haswell/avx512_1/x86_64:/usr/lib/haswell/avx512_1:/usr/lib/haswell/x86_64:/usr/lib/haswell:/usr/lib/avx512_1/x86_64:/usr/lib/avx512_1:/usr/lib/x86_64:/usr/lib
lib has been loaded.
root [0]
and complains it cannot find the header files which I tried to include in the CMakeLists.txt when I try to run a macro.
root [0]
Processing macro/MAKE/MakeHitTable.cc...
In file included from input_line_10:1:
/home/user/Research/lemuon_DC-2024February/macro/MAKE/MakeHitTable.cc:6:10: fatal error: 'InDataSource.h' file not found
#include "InDataSource.h"
^~~~~~~~~~~~~~~~
root [1]
It worked fine before I updated my root version, which was 6.22.
The attached is the CMakeLists.txt and the shell script to compile.
I thought "find_packag(ROOT 6.10 CONFIG REQUIRED) would take care of setting the correct path for root related directories, but I see empty path when I echo $ROOT_LIBRARIES.
It this causing the problem?
Any help would be greatly appreciated.
ser@user-desktop:~/Research/lemuon_DC-2024February$ echo $PATH
/opt/root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin
user@user-desktop:~/Research/lemuon_DC-2024February$ echo $ROOT_LIBRARIES
user@user-desktop:~/Research/lemuon_DC-2024February$ echo $ROOTSYS
/opt/root
Thank you,
Satoko
cmake_minimum_required(VERSION 3.1)
enable_language(CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
#set(ROOT_REQUIRED_COMPONENTS Minuit Spectrum)
set(PROJECT_NAME "lemuonsuperlibrary")
project(${PROJECT_NAME})
find_package(ROOT 6.10 CONFIG REQUIRED)
include("${ROOT_USE_FILE}")
separate_arguments(ROOT_EXE_LINKER_FLAGS)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../include)
set(DICT "G__${PROJECT_NAME}")
set(DICTSRC "${DICT}.cxx")
root_generate_dictionary(${DICT} Tracking.h DataSink.h Event.h InDataSource.h Singleton.h MagnetField.h RKutta.h Extrapolation.h PrimitiveData.h LINKDEF LinkDef.h)
add_library(${PROJECT_NAME} SHARED Tracking.C DataSink.C Event.C InDataSource.C Singleton.C MagnetField.C RKutta.C Extrapolation.C PrimitiveData.C ${DICTSRC})
target_compile_options(${PROJECT_NAME} PUBLIC -O2 -Wall -Wextra)
target_link_libraries(${PROJECT_NAME} PUBLIC ${ROOT_LIBRARIES} ${ROOT_EXE_LINKER_FLAGS})
Please read tips for efficient and successful posting and posting code
Please fill also the fields below. Note that root -b -q
will tell you this info, and starting from 6.28/06 upwards, you can call .forum bug
from the ROOT prompt to pre-populate a topic.
ROOT Version: 6.30
Platform: Ubuntu22.04.4 LTS
Compiler: gcc 11.4.0