Re: Linking CERNLIB to root

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed Feb 25 1998 - 13:04:09 MET


Rudolf Wedenig wrote:
> 
> Hello,
> how can I link a function from the CERNLIB to ROOT.
> 1.) I cannot link a fortran function to ROOT because the aCC compiler does
> not accept a fortran function.
> 2.) So I link to a c-program that calls the CERNLIB (fortran)
> 
> but somehow I cannot link ...
> 
> So, which is the best way to include the CERNLIB?
> 
> Cheers,
> Rudi

The CERNLIB libraries are unfortunately compiled without the option
to authorize the generation of shared libraries. This option to generate
position independant code is called "+z" on HP, fPIC on some systems.
As a consequence, you cannot generate a shared library with your classes
linked with the existing CERNLIB (On Linux, however, this works).
We had support many years ago for shared libraries versions of
libpacklib,
kernlib, etc in addition to the standard libPacklib.a. Unfortunately
this
effort was not pursued by the current CERNLIB team.

The solution to your problem is to have your own C++ main program
(using as an example the existing Root main program provided in 
$ROOTSYS/include) with the declarations of the Fortran prototype
functions
in the main program. I give an example below where I declare the
CERNLIB function DENLAN.

Rene Brun




//////////////////////////////////////////////////////////////////////////
//                                                                     
//
// RMain                                                               
//
//                                                                     
//
// Main program used to create ROOT application.                       
//
//                                                                     
//
//////////////////////////////////////////////////////////////////////////

#include "TROOT.h"
#include "TRint.h"

extern "C" Double_t denlan_(Double_t x);

extern void InitGui();
VoidFuncPtr_t initfuncs[] = { InitGui, 0 };

TROOT root("Rint","The ROOT Interactive Interface", initfuncs);

//______________________________________________________________________________
int main(int argc, char **argv)
{
   TRint *theApp = new TRint("Rint", &argc, argv, 0, 0);

   // Init Intrinsics, build all windows, and enter event loop
   theApp->Run();

   delete theApp;

   return(0);
}



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:30 MET