Error related to the interpreter information for class TNtupleD

Hello,
I am writing a short script and compiling it through CMake to create an executable file. I have defined the root (6.30.04) path in CMakeLists.txt and encountered no errors during the build process; the program finds root perfectly. However, I am receiving the following error when running the executable:

“Error in TClass::LoadClassInfo: no interpreter information for class TNtupleD is available even though it has a TClass initialization routine.”

This error is associated with the step where I am cloning a Tree. How should I deal with this?

Thank you in advance.

Hi @neerajk,
thanks for reaching out!

It seems be that the library is correctly loaded but in the context of usage the interpreter info is not reachable.
This behaviour can be linked to a few causes. Are you sure that the headers are properly parsed?

It would be useful if you could provide a small reproducer!

Cheers,
Monica

Hi @mdessole,

Thank you for your reply. I am pasting the content of my CMakeLists.txt and main program here:

--------------CMakeLists.txt------------------
cmake_minimum_required(VERSION 3.22.1)
project("NK01")
find_package(ROOT REQUIRED COMPONENTS RIO Hist Tree TreePlayer)
include_directories(${ROOT_INCLUDE_DIRS})
link_directories(${ROOT_LIBRARY_DIRS})
add_executable(AP1 src/AP.C)
target_include_directories(AP1 PUBLIC inc)
target_link_libraries(AP1 PUBLIC ${ROOT_LIBRARIES})
----------------------------------------------
---------------AP.C-----------------------------
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <TObject.h>
#include <TNtupleD.h>
#include "TMath.h"
#include <TVector3.h>
#include "Variables.h"
#include "TChain.h"
#include "PVariables.h"
#include "ReadBranches.C"
#include "AddBranches.C"
#include "Int_Vr.C"

TChain *t1=NULL;
TTree *NewTree=NULL;
using namespace std;
int main(int a1, char *argv[  ])
{
    t1 = new TChain("MT");
    TString fileName = Form("data/r%04d.root", atoi(argv[1]));
    t1->Add(fileName);
	cout<<"File Added: "<<fileName<<endl;
  	NewTree = new TTree("MT","MT");
 	NewTree = t1->CloneTree(0);
	return 0;
}
--------------------------------------------------------

I am unable to upload the data file because of the size issue and I hope this text will be enough.
Thank you,
Neeraj

With this, I am not able to reproduce the problem. Note that the code can be improved as follow:

using namespace std;
int main(int a1, char *argv[  ])
{
    auto t1 = new TChain("MT");
    TString fileName = Form("data/r%04d.root", atoi(argv[1]));
    t1->Add(fileName);
    cout<<"File Added: "<<fileName<<endl;
    auto NewTree = t1->CloneTree(0);
    return 0;
}

(i.e. in particular the call to new TTree is unnecessary (actually it is a memory leak).

Dear @pcanal,
Thank you for your response and for pointing out the corrections. However, I believe the issue is related to linking roots during CMake, as the main script runs fine for me when executed directly in the root terminal. The problem arises when attempting to create an executable using CMake.
Cheers,
Neeraj

I did not expect my code change to improve the situation you described. I still can not reproduce the problem even-though I used the CMakeLists.txt and source (beside changing the ROOT file name and tree name) as found in Error related to the interpreter information for class TNtupleD - #3 by neerajk