# "error: unknown type name" in

**URL:** <https://root-forum.cern.ch/t/error-unknown-type-name-in/31980>\
**Category:** ROOT\
**Created:** [December 12, 2018, 2:06pm UTC](https://root-forum.cern.ch/t/error-unknown-type-name-in/31980 "2018-12-12T14:06:49Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![oxon](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/oxon/32/12641_2.png) [@oxon](https://root-forum.cern.ch/u/oxon)\
**Post date:** [December 12, 2018, 2:06pm UTC](https://root-forum.cern.ch/t/error-unknown-type-name-in/31980/1 "2018-12-12T14:06:49Z")

</div>

* * *

_ROOT Version:_ 6.14/06  
_Platform:_ macOS 10.14.1 and CentOS 7  
_Compiler:_ Clang or GCC

* * *

When I execute a very simple script which uses one of the classes of my own library, I get the following error in the second execution time.

```auto
$ root
root [0] .x test.C
Info in <TGeoManager::TGeoManager>: Geometry manager, manager created
root [1] .x test.C
In file included from input_line_27:1:
/Users/oxon/ROBAST/test.C:4:3: error: unknown type name 'AOpticsManager'
  AOpticsManager* manager = new AOpticsManager("manager", "manager");
  ^
/Users/oxon/ROBAST/test.C:4:33: error: unknown type name 'AOpticsManager'
  AOpticsManager* manager = new AOpticsManager("manager", "manager");

```

In my understanding my library is automatically loaded in the first execution time, and thus the ROOT session should know about my classes. But it claims that it does not know my classes.

How do I get rid of this issue?

Here is the minimum code to reproduce the issue.  
[https://www.dropbox.com/s/2ew8maaxirfvc95/ROBAST.tgz?dl=0](https://www.dropbox.com/s/2ew8maaxirfvc95/ROBAST.tgz?dl=0)

```auto
$ tar zxvf ROBAST.tgz
$ cd ROBAST
$ make
$ root
root [0] .x test.C
root [1] .x test.C

```

This issue may be a duplicate of this thread.

> [@Unloading? a library or loading a library again?](https://root-forum.cern.ch/t/unloading-a-library-or-loading-a-library-again/24330):
>
> Hi, On another [thread](https://root-forum.cern.ch/t/loading-a-library-from-a-script/24306/5) we discussed how to load a custom library when executing a script. A solution was proposed that worked for the first execution of the script, but upon a repeated execution the script failed: I was asked to open a new thread to discuss the issue, so here it is. Thanks

But I do not understand why only the standard ROOT classes are allowed to be called multiple times. Is there any trick?

---

<div class="post-metadata">

**Author:** ![oxon](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/oxon/32/12641_2.png) [@oxon](https://root-forum.cern.ch/u/oxon)\
**Post date:** [December 13, 2018, 1:55am UTC](https://root-forum.cern.ch/t/error-unknown-type-name-in/31980/2 "2018-12-13T01:55:23Z")

</div>

It does not appear with El Capitan and ROOT 5.34/38.

---

<div class="post-metadata">

**Author:** ![Axel](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/axel/32/11084_2.png) [@Axel](https://root-forum.cern.ch/u/Axel)\
**Post date:** [December 13, 2018, 4:13pm UTC](https://root-forum.cern.ch/t/error-unknown-type-name-in/31980/3 "2018-12-13T16:13:28Z")

</div>

We still have issues reloading classes. What might work is to load your headers and libraries first, and then `.x test.C`. This is a workaround; we need to tackle the actual issue of reloading code.

---

<div class="post-metadata">

**Author:** ![oxon](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/oxon/32/12641_2.png) [@oxon](https://root-forum.cern.ch/u/oxon)\
**Post date:** [December 15, 2018, 2:09am UTC](https://root-forum.cern.ch/t/error-unknown-type-name-in/31980/4 "2018-12-15T02:09:16Z")

</div>

Thank you Axel. Is there any workaround which I can apply in my library side? I tried to put `gInterpreter->Declare("#include \"AOpticsManager.h\"");` in a ` __attribute__ ((constructor)) static void` function so that `#include` is automatically done at the time of the first library loading, but it didn’t help.

---

<div class="post-metadata">

**Author:** ![Axel](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/axel/32/11084_2.png) [@Axel](https://root-forum.cern.ch/u/Axel)\
**Post date:** [December 17, 2018, 4:37pm UTC](https://root-forum.cern.ch/t/error-unknown-type-name-in/31980/5 "2018-12-17T16:37:43Z")

</div>

Is that code actually executed when loading the library?

Is the library loaded before loading the script?

---

<div class="post-metadata">

**Author:** ![oxon](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/oxon/32/12641_2.png) [@oxon](https://root-forum.cern.ch/u/oxon)\
**Post date:** [December 18, 2018, 6:29am UTC](https://root-forum.cern.ch/t/error-unknown-type-name-in/31980/6 "2018-12-18T06:29:31Z")

</div>

> Is that code actually executed when loading the library?

Yes.

The line of `gInterpreter->Declare("#include \"AOpticsManager.h\"");` is executed right after the library is manually or automatically loaded because of the GCC or Clang’s functionality of ` __attribute__ ((constructor))`.

> Is the library loaded before loading the script?

No.

When I do not load my library before loading or executing my script, as you know, the library loading process is of course automatically done.

I tried three different cases.

1. NG

```auto
root [0] .x test.C
root [1] #include "AOpticsManager.h"
root [2] .x test.C

```

1. OK

```auto
root [0] #include "AOpticsManager.h"
root [1] .x test.C
root [2] .x test.C

```

1. OK

```auto
root [0] gSystem->Load("libROBAST")
root [1] .x test.C
root [2] .x test.C

```

From your explanation in the threads, I understand why cases 2 and 3 work because the `root [0]` line in both cases loads the library first. But I do not understand why the 1st case does NOT work, while inserting `#include` in the script resolves the issue.

---

<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:** [January 1, 2019, 6:29am UTC](https://root-forum.cern.ch/t/error-unknown-type-name-in/31980/7 "2019-01-01T06:29:33Z")

</div>

Closed on January 1, 2019, 6:29am UTC

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