Hi,
I’m building a custom library to analyze and simulate some detector data using ROOT classes. Recently, I moved to a scheme where I have subfolders for each component (Analysis, Simulation,…) and compile them separately. I told CMake to do so and install the headers and libraries (+ dicts) in an install dir. So far so good, but then I’m encountering a problem when including those custom headers in ROOT macros.
I narrowed down the issue to the test.zip file you have attached. If you compile it with these instructions once you unpack it:
mkdir build && cd build
cmake .. & make -jN install
Then in the install folder, you will have the includes and the libs. You have to source the thisTest.sh
file to update the LD_LIBRARY_PATH and the ROOT_INCLUDE_PATH to point to that folder.
However, if you try to execute the testSimu.cxx
macro ROOT will issue the following:
In the file included from libTestPhysics dictionary payload:5:
/media/Data/test/Physics/Kinematics.h:11:18: error: field has incomplete type 'ActPhysics::Particle'
Particle fPart;
^
libTestPhysics dictionary forward declarations' payload:5:175: note: forward declaration of 'ActPhysics::Particle'
namespace ActPhysics{class __attribute__((annotate("$clingAutoload$Physics/Particle.h"))) __attribute__((annotate("$clingAutoload$/media/Data/test/Physics/Kinematics.h"))) Particle;}
^
Error in <TInterpreter::AutoParse>: Error parsing payload code for class ActPhysics::Particle with content:
#line 1 "libTestPhysics dictionary payload"
#define _BACKWARD_BACKWARD_WARNING_H
// Inline headers
#include "/media/Data/test/Physics/Kinematics.h"
#include "/media/Data/test/Physics/Particle.h"
#undef _BACKWARD_BACKWARD_WARNING_H
This only happens when you include the fundamental header Physics/Particle.h first; if you include the Physics/Kinematics.h first (which depends on it), no issue at all!? According to the error log seems something related to the dictionary payload (although they are correctly located in the lib dir)… I had not experienced this issue until I divided the library into subfolders… Maybe somehow ROOT is unable to locate the correct header? But why in such a way that depends on the include order? I tried pointing ROOT_INCLUDE_PATH to the original headers (not the ones under install dir) but the issue is the same.
I would highly appreciate any explanation for this. Thanks in advance!
test.zip (5,2 KB)
ROOT Version: 6.28/02
Platform: Ubuntu 22.04
Compiler: Precompiled binary for that distro