RE: Compiling a root macro like a c++ program

From: Fine, Valeri <fine_at_bnl.gov>
Date: Wed, 11 Apr 2007 15:46:23 -0400


> Also, none of the ROOT shared libraries provides a main() because that
> would break all kinds> of stuff...

The ROOT (root.exe file) executable does provide the "main" ;)

> nm $ROOTSYS/bin/root.exe | grep " main"
08048894 T main

> Maybe your misunderstanding was that John tried to
> compile a standalone program, not a ROOT macro to be executed from
> within CINT (be it compiled or not).

That was the case. I thought he had the trouble to load that complied code inside of the ROOT ( I had to read his message more carefully ;). I saw his question was answered properly. He had no "./" directory on his PATH and was executing

      > which test
      > /usr/bin/test

instead of his own code.

Best Regards

                         Valeri Fine


Brookhaven National Laboratory
Upton, NY 11973, USA
Phone: +1 631 344 7806
Fax: +1 631 344 4206
E-mail: fine_at_bnl.gov

> -----Original Message-----
> From: Roland Kuhn [mailto:rkuhn_at_e18.physik.tu-muenchen.de]
> Sent: Wednesday, April 11, 2007 5:32 AM
> To: Fine, Valeri
> Cc: John Zoidberg; roottalk_at_root.cern.ch
> Subject: Re: [ROOT] Compiling a root macro like a c++ program
>
> Hi Valeri!
>
> On 10 Apr 2007, at 22:48, Fine, Valeri wrote:
>
> > Hi ,
> > replace the name of your subroutine from "main" to "test", remove
> > the parameters, try again:
> >
> > #include <stdio.h>
> > #include <stdlib.h>
> > #include <iostream.h>
> >
> > int test()
> > {
> > cout<<"Hello World!"<<endl;
> > return 0;
> > }
> >
> >
> > No application can contains TWO different subroutines with one and
> > the same name , namely "main". ROOT itself is the "main"
> > subroutine. You tried to load the second one.
> >
> Well, I just tried to link two object files containing a main()
> routine each and the linker told me:
>
> /usr/bin/ld: multiple definitions of symbol _main
> types.o definition of _main in section (__TEXT,__text)
> cd.o definition of _main in section (__TEXT,__text)
> collect2: ld returned 1 exit status
>
> So, this obviously cannot be John's problem. Also, none of the ROOT
> shared libraries provides a main() because that would break all kinds
> of stuff... Maybe your misunderstanding was that John tried to
> compile a standalone program, not a ROOT macro to be executed from
> within CINT (be it compiled or not).
>
> > -----Original Message-----
> > From: owner-roottalk_at_pcroot.cern.ch [mailto:owner-
> > roottalk_at_pcroot.cern.ch] On Behalf Of John Zoidberg
> > Sent: Tuesday, April 10, 2007 4:35 AM
> > To: roottalk_at_root.cern.ch
> > Subject: [ROOT] Compiling a root macro like a c++ program
> >
> > I would like to make programs using ROOT classes, but compiled with
> > the gcc/g++ compilers instead of this weird ACLiC/CINT system.
> > I tried to understand the Makefile of the "test" folder with all
> > the example programs, but it looks completely obscure to me.
> >
> > So I just tried reusing the command lines used when running this
> > makefile, to compile a simple "hello world" program containing no
> > ROOT code a all for the moment:
> >
> >
> > g++ -O -Wall -fPIC -pthread -I/misc/cbmsoft/Debian3.1/new/tools/
> > root/include -c test.cxx
> > g++ -O test.o /u/mtaverne/root_compilation/libEvent.so -L/misc/
> > cbmsoft/Debian3.1/new/tools/root/lib -lCore -lCint -lHist -lGraf -
> > lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -
> > pthread -lm -ldl -rdynamic -o test
> >
> > Here's the test.cxx file:
> > #include <stdio.h>
> > #include <stdlib.h>
> > #include <iostream.h>
> >
> > int main(int argc, char **argv)
> > {
> > cout<<"Hello World!"<<endl;
> > return(0);
> > }
> > (It includes more headers than needed, but that shouldn't be a
> > problem.)
> >
> > What I don't understand is that it does get compiled, but when I
> > execute it, it displays nothing (whereas it does when I compile it
> > with a simple "g++ test.cxx").
> >
>
> Ciao,
> Roland
>
> --
> TU Muenchen, Physik-Department E18, James-Franck-Str., 85748 Garching
> Telefon 089/289-12575; Telefax 089/289-12570
> --
> CERN office: 892-1-D23 phone: +41 22 7676540 mobile: +41 76 487 4482
> --
> Any society that would give up a little liberty to gain a little
> security will deserve neither and lose both. - Benjamin Franklin
> -----BEGIN GEEK CODE BLOCK-----
> Version: 3.12
> GS/CS/M/MU d-(++) s:+ a-> C+++ UL++++ P+++ L+++ E(+) W+ !N K- w--- M
> + !V Y+
> PGP++ t+(++) 5 R+ tv-- b+ DI++ e+++>++++ h---- y+++
> ------END GEEK CODE BLOCK------
>
Received on Wed Apr 11 2007 - 21:46:54 CEST

This archive was generated by hypermail 2.2.0 : Wed Apr 11 2007 - 23:50:02 CEST