Re: [ROOT] how to ... with compiled programs

From: Christian Holm Christensen (cholm@hehi03.nbi.dk)
Date: Thu Sep 06 2001 - 19:03:48 MEST


Hi, 

On Thu, 6 Sep 2001 17:29:11 +0200
Primrose Mbanefo <didi_mbanefo@laposte.net> wrote
concerning "[ROOT] how to ... with compiled programs":
> Hello everyone,
> 	I work with linux  and I would like to know how I should compile my ROOT 
> programs so that I don't need an open window(or terminal) to execute them.

I think this info is in the manual, no?  

Anyway assume that your script is foo.C and your function in that
script is thus void foo().  Then you should have a file like: 

  #ifndef __CINT__ 
  // Include all needed headers here 
  #endif 

  void foo() 
  { 
    // Put your function body here. 
    
  } 

  #ifndef __CINT__ 
  int main(int argc, char** argv) 
  { 
    // If you need graphics, uncomment the next line 
    // TApplication fooApp("fooApp", &argc, argv); 
    
    // Call you script function 
    foo(); 
 
    // If you need graphics, uncomment the next line 
    // fooApp.Run();

    return 0;
  }
  #endif 

This file can used with interactive ROOT as: 

  Root> .x foo.C 

or you can compile it to a program with 

  g++ -g -O2 -Wall `root-config --cflags --libs` foo.C -o foo 

and execute it as 

  ./foo 

BTW, I have a Emacs Lisp function that inserts a skeleton like the
above into current buffer.  Very useful.  Alos, I've defined a bash
shell function to do the above compilation too.  Yes, I know I'm lazy,
but it you write at least 1 ROOT based program a day, you really get
sick and tired of writting the same thing over and over and over and
... 

I've attached the file root-help.el, and root.profile for your
pleasure.  Hope you like it. 
    
Yours, 

Christian Holm Christensen -------------------------------------------
Address: Sankt Hansgade 23, 1. th.           Phone:  (+45) 35 35 96 91 
         DK-2200 Copenhagen N                Cell:   (+45) 28 82 16 23
         Denmark                             Office: (+45) 353  25 305 
Email:   cholm@nbi.dk                        Web:    www.nbi.dk/~cholm






This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:59 MET