Shared libraries and ROOT-6

Dear experts,

first accept my apologies in the case I’m missing something very obvious
( a similar thread is posted here : /phpBB3/viewtopic.php?f=21&t=20923 but it doesn’t answer my question ).
The code explained belowruns well with ROOT-5.34-XX, but tt fails with ROOT-6-06-00.

I want to load and run a shared library (libh.so) with CINT, but when I root -b -q the macro (run_hello.C) :

void run_hello() { gSystem->Load( "libh" ); hello my_hello; my_hello.sayhello(); }

I get the error :

[quote]In file included from input_line_9:1:
/Users/kalousis/hello/run_hello.C:6:3: error: unknown type name ‘hello’
hello my_hello;[/quote]

The (naive) hello class has been defined within libh.so and a dictionary has been created:

myd.cc : hello.h LinkDef.h @rootcint -f myd.cc -c -p hello.h LinkDef.h %.o : %.cc @$(cxx) $(cxxflags) -c -o $@ $< libh.so : hello.o myd.o @$(so) $(soflags) -o libh.so $(libs) hello.o myd.o

A simple example that reproduces the problem attached.
( makefile, hello header and source, LinkDef and a *.C macro ).
Library can be built with make, and run_hello.C runs with ROOT/CINT.

Any advice will be valuable

Many thanks in advance,
Leonidas
hello.zip (231 KB)

Dear Pepe,

thanks for your answer, and apologies for my second post.
I had a look at the links you provided but I really couldn’t figure out the solution to my problem
( I continued using ROOT-5 since I had to progress ).

Of course I am missing something.
But, please, could you elaborate a bit more on your answer.

Many thanks,
Leonidas

Hi,

In a recent ROOT 6 you can use R__LOAD_LIBRARY:

R__LOAD_LIBRARY(libh)
void run_hello() {
  hello my_hello;
  my_hello.sayhello(); }

Think of it as an #include for libraries.

Cheers, Axel.

Dear Axel,
yes, that solved the problem with ROOT-6-06-04.
Thanks a lot, Leonidas

Dear all,

thanks again for all your replies.
I have, nonetheless, one remaining problem.

While introducing a namespace in my project like :

//header 
namespace SType
{
  enum Shape { Point, Line };
        
};
//source 
#include "SType.h"
namespace SType
{}

and propagating it in the dictionary, etc …, in the usual way, when I run the macro :

R__LOAD_LIBRARY(libh)
void run_hello() {
  SType::Shape s1;
  hello my_hello;
  my_hello.sayhello(); }

I get the error :

This runs well with ROO-5-34-XX.

The error comes with :
ROOT 6.06/04
Apple LLVM version 7.0.0 (clang-700.0.72)

Any idea will be appreciated

Many thanks in advance,
Leonidas

Hi,

In your script, after R__LOAD_LIBRARY, you could just add #include “header.h”, where “header.h” is the file you showed as starting with “//header”.

Cheers, Axel.