[ROOT] Problem linking CERNLIB

From: Dan Krop (dkrop@indiana.edu)
Date: Fri Jul 26 2002 - 19:13:53 MEST


Hello ROOTers,
	I'm new to the list and have what might be a trivial question.  I am 
attempting to use the MATHLIB function RASLGF in ROOT.  I've downloaded the 
TF77 tarball from the HOWTO page and added the function I need to it.  The 
module makes without error.  When I try to test the function, however, I get 
the error-
Error: class,struct,union or type $TF77 not defined

I can find no significant differences between my code and the example included 
in the tarball, which runs correctly.  Below are the relevant files:

/* TF77.cxx
 *
 *F77 functions to be built into the root.exe executable.
 * 
 */

#include "TF77.hxx"
#include <stdio.h>
#include <stream.h>
#include "TROOT.h"
#include "Api.h"

ClassImp(TF77)

namespace F77 {
  extern "C" {
    
    /*  Define CERNLIB F77 common blocks for the different OSs, if needed. */
    
#if 0 /* define 1 if CERNLIB F77 commons are needed, 0 otherwise */
#define PAWC_SIZE 2000000
#ifndef WIN32
    int pawc_[PAWC_SIZE];
    int quest_[100];
    int hcbits_[37];
    int hcbook_[51];
    int rzcl_[11];
#else /* WIN32 */
#define pawc_   PAWC
#define quest_  QUEST
#define hcbits_ HCBITS
#define hcbook_ HCBOOK
#define rzcl_   RZCL
    extern int pawc_[PAWC_SIZE];
    extern int quest_[100];
    extern int hcbits_[37];
    extern int hcbook_[51];
    extern int rzcl_[11];
#endif /* WIN32 */
#endif /* CERNLIB F77 commons are needed */
    
  }/* end of extern "C" */

}/* end of namespace F77 */

//Legendre Polynomials - MATHLIB C330

void TF77::raslgf(Int_t &mode, Float_t &x, Int_t &m, Int_t &nl, Float_t
 &p){
  
  F77::raslgf_(mode, x, m, nl, p);//call the CERNLIB FORTRAN function

}

// Default ctor used to initialize resources used by TF77
// (i.e. FORTRAN common blocks, ...).

TF77::TF77()
{
  if (gF77 != 0) delete gF77;
  gF77 = this;
  
  // Begin of code that is needed to initialize the F77 interface.
  
  
  
  // End of code that is needed to initialize the F77 interface.
  
}

// Default dtor used to clean up and free resources used by TF77
// (i.e. FORTRAN common blocks, ...).

TF77::~TF77()
{
  if (gF77 != this) return;
  gF77 = (TF77 *)0;
  
  // Begin of code that is needed to de-initialize the F77 interface.
  
  
  
  // End of code that is needed to de-initialize the F77 interface.
  
}

// Creation of the single, global instance of the TF77 object.
TF77 *gF77 = (TF77 *)0; // First make sure gF77 is 0, then ...
TF77 *gF77Origin = new TF77(); // ... create the single instance.

/* end of file TF77.cxx */
---------------------------------------------------------------------------------------------
//TF77.hxx
//TF77 header file

#ifndef TF77_HXX
#define TF77_HXX

#if !defined (__CINT__) || defined (__MAKECINT__)
#include "Rtypes.h"
#endif

#ifndef __CINT__

namespace F77 {
  
  extern "C" {
    
    /* The interface to F77 functions and subroutines. */
    
#ifndef WIN32
#define type_of_call
#define DEFCHAR  const char*
#define PASSCHAR(string) string
#else /* WIN32 */
#define type_of_call  _stdcall
#define DEFCHAR  const char*, const int
#define PASSCHAR(string) string, strlen(string)

#define raslgf_ RASLGF
#endif /* WIN32 */

    extern void type_of_call raslgf_(Int_t &mode, Float_t &x, Int_t &m, Int_t 
&nl, Float_t &p);
  } /* end of extern "C" */

} /* end of namespace F77 */

#endif /* __CINT__ */


class TF77 {
public:
  
  static void raslgf(Int_t &mode, Float_t &x, Int_t &m, Int_t &nl, Float_t
		     &p);
  
public:
  TF77(); // Default ctor used to intialize F77 resources
  virtual ~TF77(); // Default dtor used to clean up and free F77 resources

  ClassDef(TF77,0) //C++ glue code for CERNLIB FORTRAN functions
    };

R__EXTERN TF77 *gF77; // Single, global instance of the TF77 object

#endif /* TF77_HXX */

/* end of file TF77.hxx */
----------------------------------------------------------------------------------------------
//TF77LinkDef.h
#ifdef __CINT__
#pragma link off all typedefs;
#pragma link off all globals;
#pragma link off all functions;
#pragma link off all classes;

#pragma link C++ global gF77;
#pragma link C++ class TF77;

#endif

/* End of file TF77LinkDef.h */
----------------------------------------------------------------------------------------------
//leg_test.cxx
//ROOT macro testing RASLGF (MATHLIB C330)

#include <stdio.h>
#include <math.h>

#include "TROOT.h"
#include "TCanvas.h"
#include "TPad.h"
#include "TF1.h"
#include "TGraph.h"
#if !defined (__CINT__) || defined (__MAKECINT__)
#include "Api.h"
#endif

#include "TF77.hxx"

void leg_test(void)
{

  int i;
  float x=.5;
  int mode=2;
  int m=0;
  int nl=1;
  float p[2];

  gROOT->Reset();
  

  TF77::raslgf(mode,x,m,nl,p);
  
  cout<<"P00(.5)= "<<p[0]<<endl;
  cout<<"P10(.5)= "<<p[1]<<endl;

}
---------------------------------------------------------------------------------------------

If anyone could help me figure this out, it would be much appreciated.


						Thanks in advance,
						                           Dan



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:01 MET