I’m new to root and C++ and Linux…
I have a MyClass.h and a MyClass.C file.
If I try to type
.x /Users/burial/Applications/root_v6.18.04/MyClass.C
I can successfully define
MyClass* t = new MyClass()
But when I try to run a .C file as shown:
#include "/Users/burial/Applications/root_v6.18.04/MyClass.h"
//.x /Users/burial/Applications/root_v6.18.04/MyClass.C
int main()
{
MyClass* t = new MyClass();
TTree *tgood = new TTree("tgood","");
double pt;
tgood->Branch("pt", &pt, "pt/D");
int nTracks = t->Event_multi;
t->GetEntry(1);
nTracks = t->Event_multi;
for(int i=0; i<nTracks; i++) {
double px = t->Px[i];
double py = t->Py[i];
double pz = t->Pz[i];
TVector3 mom(px,py,pz);
pt = mom.Perp();
tgood->Fill();
}
TFile f("/Users/burial/Desktop/test.root", "recreate");
tgood->Write();
f.Close();
return 0;
}
It couldn’t work and shows like:
root [2] .x /Users/burial/Desktop/test.cpp
IncrementalExecutor::executeFunction: symbol '_ZN8TVector3C1Eddd' unresolved while linking [cling interface function]!
You are probably missing the definition of TVector3::TVector3(double, double, double)
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol '_ZN7MyClassC1EP5TTree' unresolved while linking [cling interface function]!
You are probably missing the definition of MyClass::MyClass(TTree*)
Maybe you need to load the corresponding shared library?
I don’t know how to load the corresponding shared library. I tried the following command and it didn’t work:
.x /Users/burial/Applications/root_v6.18.04/MyClass.h++
ROOT_prompt_3:1:1: error: expected expression
/Users/burial/Applications/root_v6.18.04/MyClass.h++
^
ROOT_prompt_3:1:2: error: use of undeclared identifier 'Users'
/Users/burial/Applications/root_v6.18.04/MyClass.h++
^
ROOT_prompt_3:1:8: error: use of undeclared identifier 'burial'
/Users/burial/Applications/root_v6.18.04/MyClass.h++
^
ROOT_prompt_3:1:15: error: use of undeclared identifier 'Applications'
/Users/burial/Applications/root_v6.18.04/MyClass.h++
^
ROOT_prompt_3:1:28: error: use of undeclared identifier 'root_v6'
/Users/burial/Applications/root_v6.18.04/MyClass.h++
What can I do to load the Corresponding shared library?
And there’s two other little questions, when I write a .C file and try to run it in root, should I put it in the same directory where root is? And I just tried type “echo $ROOTSYS”, it just shows blank, but I can still access the tutorials by “cd $ROOTSYS/tutorials” what’s wrong with this?
Thank you in advance.
(English is not my native language, if there’s some grammar mistakes please forgive them.;))
_ROOT Version:6.18/04
_Platform:Mac OSX Catalina 10.15.2
_Compiler:Mac OSX Terminal