# Building custom library: issue when including custom-installed headers in macro

**URL:** <https://root-forum.cern.ch/t/building-custom-library-issue-when-including-custom-installed-headers-in-macro/55896>\
**Category:** ROOT\
**Tags:** cling, root\
**Created:** [August 2, 2023, 8:51am UTC](https://root-forum.cern.ch/t/building-custom-library-issue-when-including-custom-installed-headers-in-macro/55896 "2023-08-02T08:51:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![loopset](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/3ab097/32.png) [@loopset](https://root-forum.cern.ch/u/loopset)\
**Post date:** [August 2, 2023, 8:51am UTC](https://root-forum.cern.ch/t/building-custom-library-issue-when-including-custom-installed-headers-in-macro/55896/1 "2023-08-02T08:51:24Z")

</div>

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:

```auto
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:

```auto
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](https://root-forum.cern.ch/uploads/short-url/9B7xdvoTcFT1GIqloDXUFLWP5oL.zip) (5,2 KB)

_ROOT Version:_ 6.28/02  
_Platform:_ Ubuntu 22.04  
_Compiler:_ Precompiled binary for that distro

* * *

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [August 7, 2023, 1:17pm UTC](https://root-forum.cern.ch/t/building-custom-library-issue-when-including-custom-installed-headers-in-macro/55896/2 "2023-08-07T13:17:40Z")

</div>

Hi,

Maybe @vvassilev has an explanation for this. However, since you generate the dictionary you don’t need to add any include in your macro. So I would avoid adding them and I would remove both

Lorenzo

---

<div class="post-metadata">

**Author:** ![loopset](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/3ab097/32.png) [@loopset](https://root-forum.cern.ch/u/loopset)\
**Post date:** [August 17, 2023, 7:13pm UTC](https://root-forum.cern.ch/t/building-custom-library-issue-when-including-custom-installed-headers-in-macro/55896/3 "2023-08-17T19:13:41Z")

</div>

Hi!

Thanks for the reply. Yes, I am aware of that. But what happens is that some IDEs require including the header files to provide code completion (which is very useful when working with these programs), so I would like to keep writing them.

I found a workaround: modify the CMake structure of the program to not work with subdirectories when including headers in the source code (`#include "Physics/Particle.h` changed to `#include "Particle.h"`). In so doing, no errors are prompted… But still, I am wondering why the previous structure was troublesome.

Greetings!

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [August 31, 2023, 7:14pm UTC](https://root-forum.cern.ch/t/building-custom-library-issue-when-including-custom-installed-headers-in-macro/55896/4 "2023-08-31T19:14:39Z")

</div>

Closed on August 31, 2023, 7:14pm UTC

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