Hi rooters!
I know how to write ROOT macros compilable with ACLiC inside the ROOT framework. Now my question is the following: can I write a standard C/C++ main() including ROOT components and then compile the code with gcc/g++?
I tried to write a simple C++ main() specifying the full path of some ROOT libraries (e.g. “/opt/root/include/TH1F.h” with ROOT installed in the /opt directory) but when I compile it with g++ the compilation fails and I get numerous errors!
Here’s my simple code:
#include <iostream>
#include "/opt/root/include/TH1F.h"
#include "/opt/root/include/TRandom3.h"
#include "/opt/root/include/TCanvas.h"
int main(int argc, char* argv[] ){
std::cout << "This is a test" << std::endl;
TH1F *histo = new TH1D("histo","MyHisto",100,0,1);
TCanvas *cvs = new TCanvas();
for(int i = 0; i < 10000; ++i)histo->Fill( gRandom->Rndm() );
cvs->cd();
histo->Draw();
return 0;
}
Where am I wrong? Do I need a Makefile?
As a matter of fact, I started to work with the CMS collaboration and its huge CMSSW framework and I ‘discovered’ that the most part of the data analysis code uses the ROOT components but it’s compiled outside ROOT!
Hence I’d like to understand how to compile a standard C/C++ program including ROOT features.
Any answer or example would be appreciated!
Best regards!
luca