Cout library

Hi,

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

#ifndef CINT
#include
#include
#include <stdio.h>
#include
#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)

#endif
{

cout<<“hola”<<endl;

}

Then when I compile it, it complains like this:

g++ -I. -I/usr/local/root/include/ -O0 -g -Wall -fPIC -c hola.cc
hola.cc: In function int main(int, char**)': hola.cc:29: error:cout’ undeclared (first use this function)
hola.cc:29: error: (Each undeclared identifier is reported only once for each
function it appears in.)
hola.cc:29: 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 hola.cc
In file included from /usr/include/c++/3.3.3/backward/iostream.h:31,
from hola.cc:3:
/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 17.4.1.2 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;
Axel.