ACLiC complains about almost everything, why doesn't it recognize any ROOT Types like TCanvas etc?

Hi everyone,

I have a macro that runs smoothly and produces all the desired results when I run it using:

.x macro.cpp

But when I try to compile it using:

.L macro.cpp+

it complains about almost everything ! It does not recognize TCanvas, TTree etc. There are so many errors that I need to attach the error report as a text file.error.txt (4.02 KB)

The structure of my macro is:

#include "header1.h"
#include "heade2.h"

void macro(TString filen1)

  TGraphErrors *g = header1(filen1);
  TCanvas* c_pin = new TCanvas("c_pin",filen1,0,0,800,600);

The header1.h file has the following structure:

TGraphErrors* header(TString filen1)

std::vector< std::vector<double> > vec;

// a lot of things.... where we fill the vector "vec"

TGraphErrors *g = new TGraphErrors(vec[0].size(), &vec[0][0], &vec[1][0], &vec[2][0], &vec[3][0]);;

return g;

Suppose that my c++ syntax is fine, how can I avoid those “TBlahBlah” doesn’t name a type errors ?


#include “TGraphErrors.h”
#include “TCanvas.h”
#include “TString.h”
#include “TApplication.h”

Thanks a lot, that eliminated all the errors except this one:

/home/.../macros/macro_cpp_ACLiC_dict.o: In function `macro()':
macro_cpp_ACLiC_dict.cxx:(.text+0xdd2): undefined reference to `header1(TString)'
collect2: error: ld returned 1 exit status
Error in <ACLiC>: Compilation failed!

I checked and rechecked, there’s no problem with the definition/declaration of the function (header1(TString)) in header1.cpp and header1.h, no spelling or type of data issues… and it’s obvious because my code works smoothly if I don’t try to compile and just execute using .x macro.cpp.

The “header1.h” file, which you show in your first post here, defines:
TGraphErrors* header(TString filen1)
and there is no “header1” inside.

You can also try:
root [0] .L header1.cpp+
root [1] .L macro.cpp+

That was a typo, header1 or header it’s the same, it’s a fake name I am using just for this post. I have two files: header1.cpp containing the full definition and header1.h containing just the declaration. I have included header1.cpp and the macro.cpp both contain the header1.h file.

The next part of your answer solved the problem, I had to compile all source files in order of their occurrences. I have a mixed feeling about this, If a program is complicated and long, I have to first list down all the headers in order of their occurrences and compile in that order, which is a bit annoying ! Is there a way around this ?

By the way can anyone please help me with the next step, so after compiling all my source files:

.L macro.cpp+
.L header1.cpp+
.L header2.cpp+
.L header.cpp+

I have several .so files (, what should be the next step ? How can I link them ? In usual g++ I know what to do but in CINT I am blind.


You could write a Makefile, to compile all your sources into a single library. Then in ROOT you just load that library. See for instance test/Makefile and its EVENTSO.

Cheers, Axel.