"error: unknown type name" in


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.

$ 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

$ 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.

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

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

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.

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.

Is that code actually executed when loading the library?

Is the library loaded before loading the script?

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
root [0] .x test.C
root [1] #include "AOpticsManager.h"
root [2] .x test.C
  1. OK
root [0] #include "AOpticsManager.h"
root [1] .x test.C
root [2] .x test.C
  1. OK
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.

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