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

From: Fine, Valeri <fine_at_bnl.gov>
Date: Tue, 10 Apr 2007 16:48:10 -0400


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.

 Hope this helps. Valeri

-----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"). Received on Tue Apr 10 2007 - 22:48:26 CEST

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