Error while compilation .cc file with ROOT functions

Hello everyone!

I can’t comlipe c++ file with ROOT functions. That is my code:

#include <iostream>
#include <TGraphErrors.h>
#include <vector>

int main()
std::vector <double> x{1,2,3,4,5,25,6,134,1,6,24,25,124,7,4,235,12,23,4,12,43,13,134,13,3};
std::vector <double> y{12,42,12,5,21,54,2,12,5,4,654,12,6,23,14,3,54,125,12,23,4,21,21,4,4};

TGraphErrors *graph = new TGraphErrors(x.size(),,;

TCanvas polotno("canvas");

return 0;

I am compiling it using this command:

g++ -std=c++0x `root-config --cflags --ldflags --libs`

And I get a such error:

/usr/bin/ld: cannot find -lGraf3d
/usr/bin/ld: cannot find -lPostscript
/usr/bin/ld: cannot find -lPhysics
collect2: error: ld returned 1 exit status

Check if you have these libraries in:
ls -al `root-config --libdir`

In the list what I had, I didn’t find this libraries. What I gona do?

Talk to the one who installed your ROOT.

You might want to replace



#include <TCanvas.h>

note the space

also you can just use

g++ $(root-config --cflags --ldflags --libs) -o test

Note also that not all libraries from ROOT are included in $(root-config --libs), so you may have to add a few by hand when compiling your own code.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.