Root library in c++ program - compile errors

Hi,I am having problems with compiling my c++ program which uses root libraries.
My code of root1.cpp is below:

[code]#include
#include <TRandom1.h>

int main(void) {
TRandom1* myrand = new TRandom1();
for(int i=0;i<10;++i) {
std::cout << myrand->Gaus(5,1) << std::endl;
}
return 0;
}[/code]
and when i ran

i get this error message:

/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
But when I start root by typing root and executing the same file by typing .x root1.cpp It works without any problems.
Surely I have to change function name from main to roo1.

So why It doesnt compile? What I am doing wrong?

Any help would be appreciated.

Rfilip

PS: I am running Ubuntu 12.10. Root comes from package libroot-core-dev from ubuntu repository.
Root version is ROOT 5.34/00 (branches/v5-34-00-patches@44555, Sep 09 2012, 21:48:00 on linuxx8664gcc)

Install all “libroot-", "root-plugin-”, “root-system-*” (except for “root-system-rootd”) and the “ttf-root-installer” packages.

1 Like

Thanks, as I get to pc I’ll instal that packages and I’ll write here the result.

Thanks again,
I installed libroot-* packages, then I tried to install root-plugin-* packages but the instalation fails.
So I try to compile my program and voila, it compiles and run without any problems.

Does anyone know how to install these packages in windows?
(I am using root 5.34.36
I have the same problem.
This is my code ( I save it as a .cpp file and try to execute it outside root using g++ (filename).cpp) and i get the error :

#include <iostream>
#include <TObject.h>
#include <TROOT.h>
#include<TFile.h>
#include <TTree.h>
using namespace std;
int main ()

{
	cout << "Hellow World" << endl;
	return 0;
}
C:\Users\DEBAJY~1\AppData\Local\Temp\ccgInqnq.o:rootpr.cpp:(.text+0x92): undefined reference to `TVersionCheck::TVersionCheck(int)'
collect2.exe: error: ld returned 1 exit status