Set up ROOT and Code::Blocks

Hello all,

I’m relatively new to ROOT, and thus far I’ve been working with a C++ program that makes use of the ROOT libraries. I’ve been using g++ to compile my code at the command line, and would like to move to Code::Blocks. (I’m using Ubuntu 11.04 x32, ROOT 5.28.00e and Code::Blocks 10.05.)

So far when I compile, I start a new Terminal window, run

. /home/jasper/gate/root_5.28.00e/bin/thisroot.sh

and compile my code with

g++ myinput.c -o myoutput `root-config --cflags --libs`

I have not made any permanent setup for my environment variables.

In Code::Blocks, I added root-config --cflags --libs to:

Project -> Build options… -> [Project name] -> [GNU GCC Compiler] -> Compiler settings -> Other options, and
Project -> Build options… -> [Project name] -> [GNU GCC Compiler] -> Linker settings -> Other linker options

in order to pass the same option to the compiler. However it seems that this fails because the environment variables are not set within the context of Code::Blocks and thus root-config cannot be found. To fix this I’ve tried adding

. /home/jasper/gate/root_5.28.00e/bin/thisroot.sh

to Project -> Build options… -> [Project name] -> [GNU GCC Compiler] -> Pre/post build steps -> Pre-build steps, however Code::Blocks replies with a “bad substitution” error. Removing the leading ". " I then get a “permission denied” error.

I’ve tried adding that same line to my .profile file, but that left me unable to login! That’s fixed now, but is not an experience I’d want to repeat… [-o<

I was wondering if there was anyone using Code::Blocks who could share their experience with me. Or if someone could help me set up my environment (safely!), I would really appreciate that. Thanks!

Hi,

The easiest way is to run the script, in the same shell session as and before you start the Code::Block executable.

Cheers,
Philippe.