Cout library


I can’t compile anything that includes cout. This is an example of my code:

#ifndef CINT
#include <stdio.h>
#include “TROOT.h”
#include “TNtuple.h”
#include “TStyle.h”
#include “TFile.h”
#include “TString.h”
#include “TH1F.h”
#include “TCanvas.h”
#include “TTree.h”
#include “TFormula.h”
#include “TGraph.h”
#include “TStyle.h”
#include “TApplication.h”

TROOT root (“Stability”,“Stability”);
int main(int argc, char **argv)




Then when I compile it, it complains like this:

g++ -I. -I/usr/local/root/include/ -O0 -g -Wall -fPIC -c In function int main(int, char**)': error:cout’ undeclared (first use this function) error: (Each undeclared identifier is reported only once for each
function it appears in.) error: `endl’ undeclared (first use this function)
make: *** [hola.o] Error 1

Then, if I do: #include <iostream.h> it works but it says:

g++ -I. -I/usr/local/root/include/ -O0 -g -Wall -fPIC -c
In file included from /usr/include/c++/3.3.3/backward/iostream.h:31,
/usr/include/c++/3.3.3/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section of the C++ standard. Examples include substituting the header for the <X.h> header for C++ includes, or instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.
g++ -O0 -g hola.o -L/usr/local/root/lib -lCore -lCint -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lGui -lpthread -lm -ldl -rdynamic -L/usr/lib -lcurses -o hola

Do you know what’s going on? What exactly should I include? Just in case, I’m running Linux Fedora C2.

That’s c++: cout, endl etc are in the std namespace. Write std::cout<<“works.”<<std::endl; or using std;