Hi there! I can’t comlipe c++ files with TGraphErrors.h . That is my code:
#include<iostream>
#include<math.h>
#include<vector>
#include<TGraphErrors.h>
#include <TCanvas.h>
double k=pow(10,-9);
std::vector<double> lambda_ = {486.1*k,656.3*k,589.3*k};
std::vector<double> fi = {45/3600,45+5/3600,45+19/3600};
int main(){
std::vector<int> dx,dy;
for(int i=0; i<fi.size(); i++){
dx.push_back(32*pow(10,-9));
dy.push_back(32*pow(10,-9));
}
TGraphErrors graph(fi.size(),lambda_.data(),fi.data());
graph.SetTitle("#Delta T vs t[s];t[s];#Delta T");
TCanvas canvas("canvas");
graph.Draw("*AP");
canvas.Print("canvas.pdf");
return 0;
}
I am compiling it using this command:
g++ -std=c++11 root-config --cflags --ldflags --libs
lab3.cc
And I get a such error:
/tmp/cc2rvrT9.o: In function `main':
lab3.cc:(.text+0x100): undefined reference to `TGraphErrors::TGraphErrors(int, double const*, double const*, double const*, double const*)'
lab3.cc:(.text+0x114): undefined reference to `TGraph::SetTitle(char const*)'
lab3.cc:(.text+0x132): undefined reference to `TCanvas::TCanvas(char const*, char const*, int)'
lab3.cc:(.text+0x146): undefined reference to `TGraph::Draw(char const*)'
lab3.cc:(.text+0x15a): undefined reference to `TPad::Print(char const*) const'
lab3.cc:(.text+0x16e): undefined reference to `TCanvas::~TCanvas()'
lab3.cc:(.text+0x17d): undefined reference to `TGraphErrors::~TGraphErrors()'
lab3.cc:(.text+0x1c0): undefined reference to `TCanvas::~TCanvas()'
lab3.cc:(.text+0x1d4): undefined reference to `TGraphErrors::~TGraphErrors()'
/tmp/cc2rvrT9.o: In function `__static_initialization_and_destruction_0(int, int)':
lab3.cc:(.text+0x27d): undefined reference to `TVersionCheck::TVersionCheck(int)'
/tmp/cc2rvrT9.o: In function `TCanvasImp::IsA() const':
lab3.cc:(.text._ZNK10TCanvasImp3IsAEv[_ZNK10TCanvasImp3IsAEv]+0xd): undefined reference to `TCanvasImp::Class()'
/tmp/cc2rvrT9.o: In function `TCanvasImp::ShowMembers(TMemberInspector&) const':
lab3.cc:(.text._ZNK10TCanvasImp11ShowMembersER16TMemberInspector[_ZNK10TCanvasImp11ShowMembersER16TMemberInspector]+0x11): undefined reference to `TCanvasImp::Class()'
lab3.cc:(.text._ZNK10TCanvasImp11ShowMembersER16TMemberInspector[_ZNK10TCanvasImp11ShowMembersER16TMemberInspector]+0x27): undefined reference to `ROOT::Class_ShowMembers(TClass*, void const*, TMemberInspector&)'
/tmp/cc2rvrT9.o:(.rodata._ZTV10TCanvasImp[_ZTV10TCanvasImp]+0x100): undefined reference to `TCanvasImp::Streamer(TBuffer&)'
collect2: error: ld returned 1 exit status