Create a library from cling script


Is there a way to create a library with cling script and load it into a c++ code.
Something like a function declared in cling (library named

void funcA(void *b){
   int &a = *(int*)b;

Make this into a library and load it into c++ code to execute the function from the library.

int main(int argc, const char* const* argv){
cling::Interpreter interpreter(argc,argv, LLVMDIR);
//Load Library and call funcA() from the script. How to?

No, only ROOT has that.

But why would you want to do that here? Why don’t you just invoke funcA as shown in for plutification()?

Cheers, Axel.

Thanks Alex. Yes, I went through the demo and the “plutification” example works fine.
Although, there is a part of the design where we need to use functions written by others(custamization like). We are currently using Lua bindings for it and trying to move to cling instead. Would a LoadFile() that has the function definitions work in this scenario? If, so, after loading the file, will the functions be accessible with function pointers?


Cheers, Axel

Tried that after typing in reply and it works! Thanks Axel.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.