Compiling a c program with ROOT and CFITSIO libraries

I’m using ROOT 5.34/03 (tags/v5-34-03@46856, Oct 27 2012, 23:19:27 on macosx64) and CFITSIO for my analysis, actually I wrote a c program MuonRings.C that recall ROOT and CFITSIO libraries and I compile it in this way :

g++ -o MuonRings MuonRings.C -pthread -m64 -I/usr/local/ROOTd/root_v5.34.03/include -L/usr/local/ROOTd/root_v5.34.03/lib -lGui -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lpthread -Wl,-rpath,/usr/local/ROOTd/root_v5.34.03/lib -lm -ldl

but I find these errors :

Undefined symbols for architecture x86_64:
“fcn(int&, double*, double&, double*, int)”, referenced from:
MinuitMinimization() in ccnFAi29.o
"TMinuit::TMinuit(int)", referenced from:
__static_initialization_and_destruction_0(int, int)in ccnFAi29.o
"TFITSHDU::TFITSHDU(char const*)", referenced from:
MuonRings() in ccnFAi29.o
"_main", referenced from:
start in crt1.10.6.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

Is there a solution?

Thank you very much
My Kindest Regards