Loading (third party) plain C shared libraries

Dear Rooters,

I have a third party shared library written in plain C and I know the interface to it’s
member functions. I believe it should be possible with ROOT to load the library and
call functions from it, but I failed to do this. Please, point what’s wrong with the following:

root [1] .L myshared.h
root [2] gSystem->Load(“myshared.so”)
root [3] gSystem->Load(“myshared.so”, “RawReadData”)
Note: File “/home/svirida/piNdata/./myshared.so” already loaded
root [8] gSystem->DynFindSymbol(“myshared.so”, “RawReadData”)
root [9] RawReadData("./data")
Error: RawReadData() header declared but not defined FILE:(tmpfile) LINE:1
*** Interpreter error recovered ***
root [10]

And I even tried this:

root [11] int (f)(char )
root [12] f=gSystem->DynFindSymbol(“myshared.so”, “RawReadData”)
root [13] f
(int (
root [15] *f("./data")
Error: Can not access pointer to function 0x40ec787d from interpreter(2) FILE:(tmpfile) LINE:1
Error: Function f("./data") is not defined in current scope FILE:(tmpfile) LINE:1
Possible candidates are…
filename line:size busy function type and name
Error: Illegal pointer operation (tovalue) FILE:(tmpfile) LINE:1
*** Interpreter error recovered ***

============ myshared.h =====================================
/* Function declarations */
extern “C” {
int RawReadData(char * datadir);
void FreeData(void);
int SelectData(char react, char obs, float pmin, float pmax);
double uConv(double inp, char inp_unit, char out_unit);

Versions: ROOT 3.05/05 under RH9

May be I’m missing smth ?

Thanks in advance, Dima.


The ability for CINT (and ROOT) to automatically generated the interpreter symbol for a raw shared library has not been implemented yet (eventhough we think we have a solution for Linux).

However, you can very simply do it in 2 steps (the order is important);

[quote]root [1] gSystem->Load(“myshared.so”);
root [2] .L myshared.h+[/quote]

Note the ‘+’ at the end of myshared.h

The differnece between,


Is that without the + it generated the symbol in the interpreted ONLY assuming that you do NOT have a shared library. On the other hand, with the ‘+’, it assumes that you have a library and generated the proper code to access all the symbole declared in myshared.h.