Shared library with function inside

Hi,

I am trying to make a shared library with a namespace called Test with just a simple helpers functions hello_world inside, but I found although I can make it work I always need to load the CintDict file and the shared library by myself, which is not what I expected.
Based on this tutorial and the example given here, root should load the library automatically I assumed?

Here is the tarball: Test.tar.gz (990 Bytes)
and below is the outcome:

root [0] Test::hello_world()
ROOT_prompt_0:1:1: error: 'Test' is not a class, namespace, or enumeration
Test::hello_world()
^
ROOT_prompt_0:1:1: note: 'Test' declared here
root [1] .L TestCintDict.cxx 
root [2] Test::hello_world()
Hello World!
(int) 1001164608
root [3]

I found many examples in the forum but usually demonstrating how to add a class, seems it is very different from to add a function?

Thanks

Hi,

The tutorials you are pointing to describe how to integrate ROOT into your project, which is different to making the interpreter autoload your libraries.

For this, you probably need to create a rootmap of your classes (no namespaces). You can take a look at rootcling -h to see how this works.

Hi @xvallspl,

Thanks for the reply.

Maybe I was wrong, but wasn’t the rootmap generated automatically according to the LinkDef.h?
And do I understand it correctly that you mean it is not possible to do it for namespaces?
What I am trying to do is that I have a lot of helpers functions needed to be imported and I want to put them into a namespace but not to broadcast them at top-level.

Is it simply impossible or inappropriate?

Thanks

Hi, awen.

True, the rootmap is generated, sorry I missed it. But I’m affraid it’s not possible to autoload namespaces … because they can be spread across multiple shared library.

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