Problem linking root libraries

Hello,
I’m writing a C++ code to treat and to show my data.
The C++ code uses some Root libraries (TH1D, TCanvas, TFit, TGraph etc etc…)
Usually I don’t have problem on my personal computer but now I need to use the computer in the lab. (Scientific linux 6.4 Carbon, 5.22/00 Root Version)

This is the code:

[code]#include
#include
#include
#include
#include <time.h>
#include </home/program/x86_64Linux/root_v5.12.00e/include/TCanvas.h>
#include </home/program/x86_64Linux/root_v5.12.00e/include/TPad.h>
#include </home/program/x86_64Linux/root_v5.12.00e/include/TApplication.h>
#include </home/program/x86_64Linux/root_v5.12.00e/include/TGraphErrors.h>
#include </home/program/x86_64Linux/root_v5.12.00e/include/TGraph.h>
#include </home/program/x86_64Linux/root_v5.12.00e/include/TF1.h>
#include </home/program/x86_64Linux/root_v5.12.00e/include/TAxis.h>
#include </home/program/x86_64Linux/root_v5.12.00e/include/TStyle.h>
#include </home/program/x86_64Linux/root_v5.12.00e/include/TH1.h>
#include </home/program/x86_64Linux/root_v5.12.00e/include/TSpectrum.h>
#include </home/program/x86_64Linux/root_v5.12.00e/include/TList.h>
#include </home/program/x86_64Linux/root_v5.12.00e/include/TMath.h>
#include </home/program/x86_64Linux/root_v5.12.00e/include/TVirtualPad.h>

using namespace std;
TApplication app(“gui”,0,NULL);

main (){

int ndat, ncurv;

cout << “N° of point:”;
cin >> ndat;
cout << “N° of curves”;
cin >> ncurv;

cout<<"The number of curves is: "<< ncurv <<endl;
cout << "The number of points for each curve is: " << ndat << endl<<endl;

//Create histogram
TH1I h1left(“name”,“title”,10,0.0,5.0); // (“xxxx”,“xxxx”,n°bin,xmin,xmax)

//Create and close a Canvas
TCanvas c1(“name”,“title”,10,10,200,200);
c1.Close();

cout<<“End of code”<<endl;
}
[/code]

This is the command to compile:

And this is the terminal output:

root-config: Command not found. /tmp/cchEMk0r.o: In function `main': testCanvas.cpp:(.text+0xd7): undefined reference to `TH1I::TH1I(char const*, char const*, int, double, double)' testCanvas.cpp:(.text+0x108): undefined reference to `TCanvas::TCanvas(char const*, char const*, int, int, int, int)' testCanvas.cpp:(.text+0x11c): undefined reference to `TCanvas::Close(char const*)' testCanvas.cpp:(.text+0x14e): undefined reference to `TCanvas::~TCanvas()' testCanvas.cpp:(.text+0x165): undefined reference to `TCanvas::~TCanvas()' testCanvas.cpp:(.text+0x17b): undefined reference to `TH1I::~TH1I()' testCanvas.cpp:(.text+0x198): undefined reference to `TH1I::~TH1I()' /tmp/cchEMk0r.o: In function `__static_initialization_and_destruction_0(int, int)': testCanvas.cpp:(.text+0x20c): undefined reference to `TApplication::TApplication(char const*, int*, char**, void*, int)' testCanvas.cpp:(.text+0x211): undefined reference to `TApplication::~TApplication()' /tmp/cchEMk0r.o: In function `TCanvasImp::IsA() const': testCanvas.cpp:(.text._ZNK10TCanvasImp3IsAEv[TCanvasImp::IsA() const]+0xd): undefined reference to `TCanvasImp::Class()' /tmp/cchEMk0r.o: In function `TApplicationImp::~TApplicationImp()': testCanvas.cpp:(.text._ZN15TApplicationImpD2Ev[_ZN15TApplicationImpD5Ev]+0x23): undefined reference to `TString::~TString()' /tmp/cchEMk0r.o: In function `TApplicationImp::IsA() const': testCanvas.cpp:(.text._ZNK15TApplicationImp3IsAEv[TApplicationImp::IsA() const]+0xd): undefined reference to `TApplicationImp::Class()' /tmp/cchEMk0r.o:(.rodata._ZTV15TApplicationImp[vtable for TApplicationImp]+0x78): undefined reference to `TApplicationImp::ShowMembers(TMemberInspector&, char*)' /tmp/cchEMk0r.o:(.rodata._ZTV15TApplicationImp[vtable for TApplicationImp]+0x80): undefined reference to `TApplicationImp::Streamer(TBuffer&)' /tmp/cchEMk0r.o:(.rodata._ZTV10TCanvasImp[vtable for TCanvasImp]+0xc8): undefined reference to `TCanvasImp::ShowMembers(TMemberInspector&, char*)' /tmp/cchEMk0r.o:(.rodata._ZTV10TCanvasImp[vtable for TCanvasImp]+0xd0): undefined reference to `TCanvasImp::Streamer(TBuffer&)' collect2: ld returned 1 exit status

Thank you all in advance
Regards
Cino

Hi Cino,
how is ROOT installed on your lab computer?
Could you give us the output of the terminal command

which root echo $PATH echo $LD_LIBRARY_PATH

Thank you for the answer!
These are the output:

which root
/home/cmd/root

echo $PATH
/home/prog/openmpi/openmpi-1.4-gcc/bin:
/usr/local/rsoft/bin:
/home/prog/openmpi/openmpi-1.4-gcc/bin:
/usr/local/rsoft/bin:
/home/prog/openmpi/openmpi-1.4-gcc/bin:
/usr/local/rsoft/bin:/usr/NX/bin:/usr/kerberos/sbin:
/usr/kerberos/bin:/home/prog/openmpi/openmpi-1.4-gcc/bin:
/usr/local/rsoft/bin:/bin:/usr/sbin:/usr/bin:/usr/bin/X11:
/usr/local/bin:
/opt/intel/compiler70/ia32/bin:
/opt/absoft/bin:/home/cmd:.:
/home/cao/caoutil/bin:/home/cao/caoutil/bin

echo $LD_LIBRARY_PATH
/home/prog/openmpi/openmpi-1.4-gcc/lib:
/home/prog/openmpi/openmpi-1.4-gcc/lib:
/home/prog/openmpi/openmpi-1.4-gcc/lib:
/home/prog/openmpi/openmpi-1.4-gcc/lib:
/usr/lib:
/opt/intel/compiler70/ia32/lib:
/opt/absoft/lib

For information, I have Linux access as normal user only.

Regards
Cino

Ok, your ROOT installation is quite weird.
To solve your problem you have to add the path to the ROOT binaries in your $PATH variable
You can do it by adding something like that in your .bashrc (located at $HOME/.bashrc)

[code]export PATH="/path/to/root/binaries/directory:$PATH"
export LD_LIBRARY_PATH="/path/to/root/libraries/directory:$LD_LIBRARY_PATH"

source thisroot.sh[/code]

I cannot give you the exact path, which depends on your installation, because the location of the root binary is unusual (/home/cmd/root)

EDIT: what is the output of

Is it “/home/cmd/root-config”?

I agree, it’s weird but the big problem that I’m not expert at all.

This is the output:

>>which root-config root-config: Command not found.
I supposed that

was enough to add the path to ROOT libraries.

Thanks
Cino

Ok, so you can try to add the following lines in your .bashrc (in your home directory)

export PATH="/home/cmd:$PATH" export LD_LIBRARY_PATH="/home/program/x86_64Linux/root_v5.12.00e/lib:$LD_LIBRARY_PATH"

That said, it should not solve your problem with root-config.
It will allow you to write

instead of

Concerning root-config, I do not see how to help you since root-config seems to not be installed on your computer.
Maybe the simplest way to solve this problem is to do your own local installation of ROOT. You will find some informations here

I tried this morning with the “Location independent installation” but typing

the output is

Root is already installed beacause it works in the interactive mode.

Do you have others ideas?
Otherwise don’t worry, I will try with a stand-alone computer.

Thanks
Cino

First, you have to download root clicking here.
Then, you untar the archive doing

you go in the root directory

and finally you type

Ok now it works on my personal folders!!
I used the commandsource bin/thisroot.csh is it right?

Thank you very much for the support!
Cino

Good to know,
yes you have to use

before running ROOT.
You can put this line in your .bashrc/.cshrc to load it when you open a terminal.