Using root for pythia8 historam output

i had installed pythia 8176 and root 5.32.04 version.
i copied hist.cc sample program from rootexamples directory to examples directory.
then i used

g++ -O2 -ansi -pedantic -W -Wall -Wshadow -I$PYTHIA8/include -I$FASTJET/include -I$ROOTSYS/include hist.cc -o hist

at end i got ouput as:
collect2: ld returned 1 exit status

but i did not get an executable file

Hello, could you post the previous lines before

the lines are as:
mainw71.cc:(.text.startup+0xdb2): undefined reference to fastjet::ClusterSequence::~ClusterSequence()' mainw71.cc:(.text.startup+0xdf3): undefined reference tofastjet::JetDefinition::description() const’
mainw71.cc:(.text.startup+0xe57): undefined reference to fastjet::ClusterSequence::strategy_string(fastjet::Strategy) const' mainw71.cc:(.text.startup+0xedb): undefined reference tofastjet::PseudoJet::PseudoJet(double, double, double, double)'
mainw71.cc:(.text.startup+0xf6e): undefined reference to fastjet::PseudoJet::_set_rap_phi() const' mainw71.cc:(.text.startup+0xf84): undefined reference tofastjet::PseudoJet::plain_distance(fastjet::PseudoJet const&) const’
mainw71.cc:(.text.startup+0x10ae): undefined reference to fastjet::ClusterSequence::~ClusterSequence()' mainw71.cc:(.text.startup+0x10d6): undefined reference toPythia8::Pythia::~Pythia()'
mainw71.cc:(.text.startup+0x10e3): undefined reference to TApplication::~TApplication()' mainw71.cc:(.text.startup+0x129a): undefined reference toTObject::operator delete(void*)‘
mainw71.cc:(.text.startup+0x12ac): undefined reference to TObject::operator delete(void*)' mainw71.cc:(.text.startup+0x12be): undefined reference toTObject::operator delete(void*)‘
mainw71.cc:(.text.startup+0x12d0): undefined reference to TObject::operator delete(void*)' mainw71.cc:(.text.startup+0x12e2): undefined reference toTObject::operator delete(void*)’
/tmp/ccNynXhf.o: In function _GLOBAL__sub_I_main': mainw71.cc:(.text.startup+0x13d1): undefined reference toTVersionCheck::TVersionCheck(int)’
/tmp/ccNynXhf.o:(.rodata._ZTV15TApplicationImp[vtable for TApplicationImp]+0x78): undefined reference to TApplicationImp::ShowMembers(TMemberInspector&)' /tmp/ccNynXhf.o:(.rodata._ZTV15TApplicationImp[vtable for TApplicationImp]+0x80): undefined reference toTApplicationImp::Streamer(TBuffer&)'
collect2: ld returned 1 exit status