Re: [ROOT] Calling ctvmft fortran routine in ROOT

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu Jun 20 2002 - 10:27:11 MEST


Hi Jaroslaw,

You have a typo in your main program. Also note that
it is not necessary to call the TROOT constructor.
See a modified version of your program below
When you link, I suggest to use

 g++ -o xx -O `root-config --cflags --libs`  rootVertex.cxx

This form generating the executable will work on all machines
root-config is a small utility in $ROOTSYS/bin. You can type
root-config ?
to see the list of options

Rene Brun


#include "TRint.h"
#include "Vertexfunctions.h"

int main(int argc, char **argv)
{
  
  if (0){
    Int_t iflun=0;
    Int_t iflev=0;
    Int_t ierr=0;
    Int_t result = ctvmft_(&iflun,&iflev,&ierr);
    printf("ctvmft(iflun,iflev,ierr)=%d\n", result);
  }
  
   // Create an interactive ROOT application
     

  TRint *theApp = new TRint("Rint", &argc, argv, 0, 0);

     // and enter the event loop...
     
     
     
     theApp->Run();
     
     delete theApp;

   return 0;
}


On Thu, 20 Jun 2002, Jaroslaw Nowak wrote:

> HEllo,
> I still have a problem to call fortran routine.
> I'm doing everything like in the first method in the
> http://root.cern.ch/root/HowtoCERNLIB.html
> my files:
> //Vertexfunctions.h
> #ifndef Vertexfunction_H
> #define Vertexfunction_H
> 
> 
> #if !defined (__CINT__) || defined (__MAKECINT__)
> #include "Rtypes.h"
> #endif
> 
> extern "C" Int_t ctvmft_(Int_t *iflun, Int_t *iflev, Int_t *ierr);
> 
> #endif
> 
> //VertexLinkDef.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++ function ctvmft_;
> #endif
> I execute the shhel script command:
> rootcint -f Vertex.cxx -c Vertexfunctions.h VertexLinkDef.h
> 
> My main program
> // rootVertex.cxx
> 
> #include "TROOT.h"
> #include "TRint.h"
> #include "Vertexfunctions.h"
> 
> TROOT root("Rint","The ROOT Interactive Interface");
> 
> int main(int argc, char **argv)
> {
>   
>   if (0){
>     Int_t iflun=0;
>     Int_t iflev=0;
>     Int_t ierr=0;
>     prinft("ctvmft(iflun,iflev,ierr)=%g\n", ctvmft_(&iflun,&iflev,&ierr);
> 	   }
>   
>    // Create an interactive ROOT application
>      
> 
>   TRint *theApp = new TRint("Rint", &argc, argv, 0, 0);
> 
>      // and enter the event loop...
>      
>      
>      
>      theApp->Run();
>      
>      delete theApp;
> 
>    return 0;
> }
> and after make rootVertex 
> ++ -O -Wall -fPIC -D_REENTRANT -I/usr/local/root/pro/root/include -c
> rootVertex.cxx
> rootVertex.cxx: In function `int main(int, char **)':
> rootVertex.cxx:36: parse error before `;'
> make: *** [rootVertex.o] Error 1
> 
> and if I delete part of the program:
> // rootVertex.cxx
> 
> #include "TROOT.h"
> #include "TRint.h"
> #include "Vertexfunctions.h"
> 
> TROOT root("Rint","The ROOT Interactive Interface");
> 
> int main(int argc, char **argv)
> {
> 
> /*  if (0){
>     Int_t iflun=0;
>     Int_t iflev=0;
>     Int_t ierr=0;
>     prinft("ctvmft(iflun,iflev,ierr)=%g\n", ctvmft_(&iflun,&iflev,&ierr);
>            }
> */
>    // Create an interactive ROOT application
> 
> 
>   TRint *theApp = new TRint("Rint", &argc, argv, 0, 0);
> 
>      // and enter the event loop...
> 
> 
> 
>      theApp->Run();
> 
>      delete theApp;
> 
>    return 0;
> }
> 
> $ make rootVertex 
> g++ -O -Wall -fPIC -D_REENTRANT -I/usr/local/root/pro/root/include -c
> rootVertex.cxx
> cc -O  rootVertex.o   -o rootVertex
> rootVertex.o: In function `main':
> rootVertex.o(.text+0x1b): undefined reference to
> `TStorage::ObjectAlloc(unsigned int)'
> rootVertex.o(.text+0x38): undefined reference to `TRint::TRint(char const
> *, int *, char **, void *, int, unsigned char)'
> rootVertex.o(.text+0x7d): undefined reference to `TObject::operator
> delete(void *)'
> rootVertex.o: In function `global destructors keyed to main':
> rootVertex.o(.text+0xc1): undefined reference to `TROOT::~TROOT(void)'
> rootVertex.o: In function `global constructors keyed to main':
> rootVertex.o(.text+0xf7): undefined reference to `TROOT::TROOT(char const
> *, char const *, void (**)(void))'
> collect2: ld returned 1 exit status
> make: *** [rootVertex] Error 1
> rm rootVertex.o
> 
> 
> I don't understand where is a problem. If you find what I'm doing wrong
> please sent me a massage.
> 
> Best regards,
> 
> Jarek Nowak 
> 



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