ROOT and Code::Blocks

I am trying to compile a ROOT program using the Code::Blocks IDE. In ‘Global Compiler Settings->Linker Settings’ I added all the library files in C:\root\lib, and in ‘Global Compiler Settings->Search Directories->Compiler’ I pointed it to the C:\root\include\ folder.

When I try to compile the program I get ‘undefined reference’ errors to all the ROOT functions in the code, and I have included the proper ROOT header in the code. What am I missing?

Thanks,
Eric

Hi,

don’t put all the libs into the link line; libCore.lib libCint.lib libRIO.lib libNet.lib libHist.lib libGraf.lib libGraf3d.lib libGpad.lib libTree.lib libRint.lib libPostscript.lib libMatrix.lib libPhysics.lib libMathCore.lib libThread.lib libGui.lib should be sufficient.

Which compiler and version do you use? Which exact ROOT version did you download and install? What’s the command line issues by code blocks that invokes the linker? What are the error messages?

Cheers, Axel.

I’m using the MingGW g++ compiler. I’m not sure what version it is. I’m using 5.21.04 version of ROOT.

I’m not sure, this is what the setup looks like:
http://img71.imageshack.us/my.php?image=cblibfw3.jpg

Here are the errors:
C:\root\programs\ROOTtest.o:ROOTtest.cpp:(.text+0x1a3)||undefined reference to TROOT::TROOT(char const*, char const*, void (**)())'| C:\root\programs\ROOTtest.o:ROOTtest.cpp:(.text+0x1f7)||undefined reference to TFile::TFile(char const*, char const*, char const*, int)‘|
C:\root\programs\ROOTtest.o:ROOTtest.cpp:(.text+0x21d)||undefined reference to TObject::operator delete(void*)'| C:\root\programs\ROOTtest.o:ROOTtest.cpp:(.text+0x348)||undefined reference to TH1D::TH1D(char const*, char const*, int, double, double)’|
C:\root\programs\ROOTtest.o:ROOTtest.cpp:(.text+0x3a3)||undefined reference to TObject::operator delete(void*)'| C:\root\programs\ROOTtest.o:ROOTtest.cpp:(.text+0x4cb)||undefined reference to TROOT::~TROOT()‘|
C:\root\programs\ROOTtest.o:ROOTtest.cpp:(.text+0x4fb)||undefined reference to TROOT::~TROOT()'| C:\root\programs\ROOTtest.o:ROOTtest.cpp:(.text+0x565)||undefined reference to TVersionCheck::TVersionCheck(int)’|
C:\root\programs\ROOTtest.o:ROOTtest.cpp:(.text$_ZN7TObjectnwEj[TObject::operator new(unsigned int)]+0xd)||undefined reference to `TStorage::ObjectAlloc(unsigned int)'|
||=== Build finished: 9 errors, 0 warnings ===|

Hi,

we do not support MinGW yet. Better use MS VisualC++, e.g. the free Express edition, and install the corresponding ROOT build.

Cheers, Axel.

Thanks,

I got it to compile with the Visual Studio 9.0 compiler.