Troubles compiling on ubuntu SOLVED

Dear rooters,

since I learned to use root I have been using just CINT but now I have the need to compile my code in order to run it faster. In order to learn, I made a small “hello world”, which I paste here

#include <iostream>
#include "/home/guido/root/include/TH1D.h"

using namespace std;

int main(){
  TH1D *histo;
  cout << "Hello world" << endl;
  return 0;

and tried to compile it with

g++ -I`root-config --incdir` `root-config --libs` ./test.cpp -o test.exe

but got all the plethora of errors attached. Those errors I don’t get them if I just remove the two root-related lines (the include and the histogram definition) but still compile with the same command.

My root is installed in /home/guido/root ($ROOTSYS variable) and is version 6.06/02 on ubuntu 14.04 LTS.
I don’t know if it matters somehow but I have troubles setting the environmental variables, so each time I may need them I just run the script in order to “temporarily” set them.

Any help or suggestion on how to troubleshoot this would be great, thanks in advance.

error.txt (162 KB)

[code]#include “TH1.h”

int main() {
TH1D *histo = 0;
std::cout << “Hello world” << std::endl;
return 0;
}[/code] `root-config --cxx --cflags` -o test.exe test.cpp `root-config --glibs`

Excellent, now it works!

I still have troubles making TCanvas objects appear when I draw them, but I guess I should open a new topic for that… Many thanks anyway, I wouldn’t have guessed the solution to that.

See the “${ROOTSYS}/test” subdirectory for examples.