Help in library autoloading

while, i use the makecint generate a dictionary successfully.

test.h

void test(int a,const char*str);

test.cpp

#include "test.h"
#include <stdio.h>
#include <stdlib.h>
void test(int a,const char*str)
{
   printf("%d\n",a);
   printf("%s\n",str);
}

use makecint to generate the test.dll:
makcint -mk makefile -H test.h -C++ test.cpp -dl test.dll

i can use the root 's .L statemenst to load the test.dll:
root [0] .L test.dll
then i can use the test function in the root.

but how could i let the root autoload the test.dll when it startup?
how should i modify the rootmap file in the lib dir to let root autoload the dll?
the dll is not export a class,just some global functions.

Hi,

you should use rootcint which can generate a rootmap file which is needed for autoloading to work. But that won’t help you as autoloading only works for classes. You can make your function a static class member and request a dictionary for that class - that will allow your library to be autoloaded. Instead of using rootcint to generate the rootmap file you can also use rlibmap directly which will only generate the rootmap file.

Cheers, Axel.

hi, does the class i defined had to derived from TObject?
can i add a indenpendent class into the root?
i mean should i use the macro ClassDef & ClassImp into my Class?

Hi,

you don’t need to derive the class form TObject, and you don’t need ClassDef or ClassImp. I believe that the users guide clearly explains what to use ClassDef and ClassImp for; let us know if it’s not clear enough.

Cheers, Axel.