I try to execute the next code
#include "TMath.h"
#include "TH1.h"
#include "iostream"
using namespace std;
void File()
{
TFile f("myfile.root", "CREATE");
TH1F* h = new TH1F("h", "h", 64, -4, 4);
h->FillRandom("gaus");
h->Write();
TH1F* myHist;
f.GetObject("h", myHist);
myHist->Draw();
f.Close();
}
But there emerged such a problem
IncrementalExecutor::executeFunction: symbol ‘_ZN6TClass8GetClassI4TH1FEEPS_bb’ unresolved while linking [cling interface function]!
You are probably missing the definition of TClass* TClass::GetClass(bool, bool)
Maybe you need to load the corresponding shared library?
What should I do ?
couet
May 2, 2023, 2:58pm
2
It works for me:
File.C:
#include "TMath.h"
#include "TH1.h"
#include "iostream"
using namespace std;
void File()
{
TFile f("myfile.root", "CREATE");
TH1F* h = new TH1F("h", "h", 64, -4, 4);
h->FillRandom("gaus");
h->Write();
TH1F* myHist;
f.GetObject("h", myHist);
myHist->Draw();
f.Close();
}
root [0] .x File.C
Processing File.C...
Info in <TCanvas::MakeDefCanvas>: created default TCanvas with name c1
root [1]
Axel
May 2, 2023, 3:41pm
3
This looks like an inconsistent build or setup of ROOT, where you mix versions. Can you send the output of .files
and gInterpreter->GetSharedLibs()
?
I guess you want:
TFile f("myfile.root", "RECREATE");
and:
myHist->SetDirectory(gROOT); // before closing "f"
system
Closed
May 16, 2023, 3:59pm
5
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.