This is a recipe to convert macro(s) to shared libraries (to automatize this "make" is your friend). In a future version we hope to make this more automatic and let CINT do most of the work (bypassing the rootcint step). You've to do the following: - to an existing macro, add the needed header files. Use ifdef's so you still can run the macro's via the interpreter. E.g. file myfunc.cxx: #ifndef __CINT__ #include <TH1.h> // any ROOT header #include "myheader.h" // any private header #endif void myfunc(int iopt) { // here function code } - create a header file containing the prototype of your function. E.g. myfunc.h: void myfunc(int iopt); - create a LinkDef.h file so rootcint knows what functions to process. E.g. MyLinkDef.h: #ifdef __CINT__ #pragma link off all globals; #pragma link off all classes; #pragma link off all functions; #pragma link C++ function myfunc; #endif - Run rootcint: rootcint -f mydict.cxx -c myfunc.h MyLinkDef.h - Compile the two sources: g++ -fPIC -c myfunc.cxx g++ -fPIC -c mydict.cxx g++ shared -o myfunc.so myfunc.o mydict.o - Now you are ready to use the shared lib in root. E.g.: root root [0] gSystem.Load("myfunc") root [1] myfunc(99) - myfunc() can also be used in buttons are anywhere else. Cheers, Fons. PS: to see the needed compiler options for your platform see the $ROOTSYS/test/Makefile and look how libEvent.so is compiled. HANS WENZEL, FNAL: 630 840 8240 HOME: (630) 393 1756 OR 393 1873 wrote: > > FNAL, 12-MAY-1998 > > hi > > I am just a beginner concerning root. My question is the following is there an > automatic procedure which i can use to transform working cint macros into > standalone c++ programs that i can then link with the root libraries. > e.g i would like to transform hserv.C and hclient.C from the tutorials > directory and and then run them without having to go through the root command > lines. > > cheers thanks for any help > > Hans -- 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
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:32 MET