G++ compiler does not recognize root syntax

Hello,

I am trying to compile a .cpp file in g++ compiler. The file uses root classes. My problem is that when the .cpp file is compiled it shoots several errors basically saying the syntax is wrong. For example, the way an int data type is written in root is Int_t, so the compiler considers that a syntax error, that and several others in my .cpp file.

The command I am running in my terminal is

g++ RootPlotMCcutandUncut.cpp -o RootPlotMCcutandUncut.exe `root-config --cflags --glibs`

I am running root v5.34 on a Windows Subsystem of Linux (WSL) that is an Ubuntu 14.04 version. Thank you in advance for any help offered.

Juan

You seem to be missing appropriate #include statements for the ROOT classes that you use (they will automatically define Int_t and so on, too).

These are the header files I included in the .cpp file.

#include <stdio.h>
#include <TFile.h>
#include <TCanvas.h>
#include <TH1F.h>
#include <TH2F.h>
#include <TTreeReader.h>
#include <TPaveStats.h>
#include <TStyle.h>
#include <TTree.h>
#include <TPad.h>
#include <TRatioPlot.h>
#include <TLegend.h>
#include <TLegendEntry.h>

I am not sure which header file I am missing.

With any of these ROOT #include statements, you should not get any errors related to “Int_t”.
There must be some source code bug which triggers this error (you need to go through compiler’s messages).

Already solved the problem. Turns out since I was using root-5.34 some of the header files were not supported in this version. I just downloaded root-6.09 and ran the code in the g++ compiler and had no more problems.

Thank you for the help Wile

-Juan