you have to specify in a LinkDef.h file the function you want to
export. Only for classes you don't need to specify the LinkDef.h in
case the class name is the header name minus .h (in which case
rootcint generates automatically a LinkDef.h file).
Cheers, Fons.
Example LinkDef.h:
#ifdef __CINT__
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ function cuber;
#endif
> Hello,
> I tried to make a shared library with one function in it. I was able
> to build the shared lib with no errors and load it into root. I just could
> not execute the function in the interpreter.
>
> This is the root interpreter interaction. The .h, .C and a snippet of the
> Makefile are below.
>
> Thank you in advance for your help.
>
> Chris
>
>
> root [0] gSystem->Load("libcuber.so");
> root [1] Double_t x,y;
> root [2] x =5.0;
> root [3] y = cuber(x);
> Error: No symbol null in current scope FILE:/tmp/09951daa LINE:1
> root [4]
>
> The cuber.h file was
>
> #ifndef __CUBER_H
> #define __CUBER_H
> #include "Rtypes.h"
>
> Double_t cuber(Double_t x);
>
>
> #endif
>
> The cuber.C file was
>
> #include "Rtypes.h"
> Double_t cuber(Double_t x) {
> Double_t retvar = x*x*x;
> return retvar;
>
> }
>
> I made everything with the usual procedure
>
> cuberdict.C: cuber.C cuber.h
> echo "generating cuber dictionary"
> rootcint cuberdict.C -c $(INCLUDE) $(ROOTOBJ) cuber.h
>
> cuberdict.o: cuberdict.C
> $(CXX) -c $(CXXFLAGS) cuberdict.C
>
> cuber.o: cuber.C cuber.h Makefile
> $(CXX) -c $(CXXFLAGS) $(ROOTOBJ) cuber.C
>
> libcuber: cuber.o cuberdict.o
> $(LD) $(LDFLAGS) $(SOFLAGS) cuber.o cuberdict.o $(GLIBS) \
> -o libcuber.so
>
>
> The Makefile definitions were unchanged since successfully putting classes
> into a shareled lib.
>
>
>
> =================================================================
> = =
> = Chris Jillings =
> = Department of Physics phone/voice mail: (613) 545-6000x4805 =
> = Queen's University fax: (613) 545-6813 =
> = Kingston, Ontario email: chris@sno.phy.queensu.ca =
> = Canada, K7L 3N6 web: http://sno.phy.queensu.ca =
> = =
> =================================================================
>
>
>
>
-- Org: CERN, European Laboratory for Particle Physics. Mail: 1211 Geneve 23, Switzerland Phone: +41 22 7679248 E-Mail: Fons.Rademakers@cern.ch Fax: +41 22 7677910