Dear Cling community,
We are using Cling in our project and we’re loving it so far, this is an amazing piece of work.
Many thanks for that!
What we are trying to achieve is a program that compiles and executes small scripts based on a larger library.
So far it’s working pretty well when we don’t “unload” the transaction after each execution.
Here is a small snippet that reproduce the problem :
[code]
#include
#include “cling/Interpreter/Interpreter.h”
int main() {
const char* args[] = { “test-cling”, “-I…/cling/src/tools/cling/include”, “-std=c++14” };
cling::Interpreter interp(3, args, “/usr/local/etc/root/cling/”);
interp.loadFile(“iostream”);
{
std::string scriptSrc1 = “void myFunction1() { std::cout << “Hello 1” << std::endl; }”;
if (interp.declare(scriptSrc1) != cling::Interpreter::CompilationResult::kSuccess) {
std::cout << “Declaration Failed” << std::endl;
return -1;
}
interp.unload(1); // it works properly if you comment this line.
}
std::cout << “Declared 1” << std::endl;
{
std::string scriptSrc1 = “void myFunction2() { std::cout << “Hello 2” << std::endl; }”;
if (interp.declare(scriptSrc1) != cling::Interpreter::CompilationResult::kSuccess) {
std::cout << “Declaration Failed” << std::endl;
return -1;
}
interp.unload(1);
}
std::cout << “Declared 2” << std::endl;
return 0;
}[/code]
Our compilation command line is :
g++ -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -std=c++14 -Wall -L$(brew --prefix root6)/lib/root -lCling test-cling.cc
And we’re using Root version 6.04.10.
Are we missing something?
Is there any way to achieve that properly?
Many thanks in advance for your help!
Best regards,
Yves