Packing libraries for use in and alongside ROOT

Hi all,

We are building a small library to be used in the RDF eco-system. We’d like to have it used inside ROOT from the command line, and also be available for linking if someone was building a stand-alone program.

What is the best way to package and distribute this? I’m guessing the recommended advice is to use CMAKE - any hints on using external libraries? Example CMAKE file?

Many thanks in advance!

1 Like

Hi @Gordon_Watts ,
a very basic CMakeLists.txt for a project depending on ROOT looks like this:

cmake_minimum_required(VERSION 3.9)
project (example_root_project CXX)

# Look for ROOT
# As long as an installation is available in the environment, this will succeed.
message(STATUS "Looking for ROOT")
find_package(ROOT REQUIRED COMPONENTS RIO) # can also list components that must be present
message(STATUS "ROOT ${ROOT_VERSION} found at ${ROOT_BINDIR}")


with src/CMakeLists.txt that might be similar to what you see here: root_dictionaries_tutorial/CMakeLists.txt at 3fabb4ba134eb8cea49aa119672f301bd1e557cd · eguiraud/root_dictionaries_tutorial · GitHub

Then, to use it in the ROOT prompt you would have to gSystem->Load any library object and #include any header.
To link it when building a standalone program the usual C++ methods work, e.g. adding the installation directory of the project to your LD_LIBRARY_PATH, or cloning the project into the project that depends on it and build them together via cmake.

I can help if you get stuck, although I won’t have time to put together a full blown example before at least next week.
Our build system experts @amadio @oshadura and @bellenot might have more tips and suggestions.

@Axel it would be cool to have a cookie-cutter skeleton project that people can clone to jumpstart their project.

Hi Gordon,

Here is a simple example for an executable (taken from one of my projects):

# Check if cmake has the required version

set(PROJECT_NAME View3ds)

find_package(ROOT REQUIRED)

# generate dicitonary

add_executable(${PROJECT_NAME} ${PROJECT_NAME}.cxx ${PROJECT_NAME}Dict.cxx ${PROJECT_NAME}.rc)
target_link_libraries(${PROJECT_NAME} ${ROOT_LIBRARIES} libEve libGui libGed libRGL)

Cheers, Bertrand.

1 Like

Thanks, to both of you, for this. This is more than enough for us to get started!!

Cheers, Gordon.


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.