Loading libraries in a cling script

Hello,

I want to use cling for interactive code testing and development in C++, so I have downloaded and compiled it according to the tutorial here:

root.cern.ch/cling-build-instructions

My question is very simple, unfortunately, I could not find a solution on the web: How can I load a library from within a script? I have some code which depends on external libraries, and of course it is possible to start cling and issue a command “.L libgsl.so.0” in order to have access to the GSL library. Now I would like to pack all this preliminary commands in some script, so that I just need to do something like

.x prepareWorkspace.run

and voilà, I can start testing code.

Cheers,
Christian

Hi,
Unfortunately this is not possible with current version of cling.

In prepareWorkspace.C you could do:

#include "cling/Interpreter/Interpreter.h"
void prepareWorkspace() {
  gCling->loadFile("libgsl.so.0"); // I think "libgsl" should also work.
}

and of course .x prepareWorkspace.C in cling to activate the “script”.
Cheers,
Vassil

Hey Vassil,

that’s fine, actually, that is exactly what I was looking for!

Thanks,
Christian

Hi,

On the trunk, cling -l/usr/lib/libldap.dylib works.

Cheers, Axel.