Re: Cross-compiling on Fedora 12

From: Konstantin Olchanski <olchansk_at_triumf.ca>
Date: Wed, 3 Mar 2010 11:23:36 -0800


On Tue, Mar 02, 2010 at 11:56:54AM +0100, Rene Brun wrote:
> for example, to compile and link the small program in attachment on
> Linux, you simply have to do:
>
> g++ -o hsimple hsimple.C -I$ROOTSYS/include -L$ROOTSYS/lib -lCore -lCint
> -lRIO -lHist -lTree -lm -ldl -rdynamic
>

You also have to supply the correct "-m32" or "-m64" flag to match the flavour of your ROOT binary kit. At TRIUMF it is common to run on a 64-bit machine but for sundry reasons use 32-bit compiled ROOT.

Recent versions of ROOT supply the correct "-m32/-m64" flags through "root-config --cflags"

K.O.

>
> Rene Brun
>
>
> Vassili Maroussov wrote:
> >Tried various things, but nothing worked. Finally compiled ROOT on Sun
> >VirtualBox with Fedora 12 i686 installed and copied the tree obtained
> >with "make install" to the x86_64 host. Now I can link ROOT libraries
> >to FLUKA and have the ROOT output with it, but wondered what parts of
> >that ROOT i686 directory tree if I want only:
> >
> >- Generate object dictionaries with rootcint, use ClassDef and
> >ClassImp macros;
> >- Use ROOT Collections, TTree and TFile with output only into local files
> >
> >Regards,
> >
> >Vassili
> >
> >On 03/01/2010 09:15 PM, Philippe Canal wrote:
> >>Hi,
> >>
> >>rootcint still only generate the dictionary (it only call g++ when
> >>the option -p is passed ... and then __only__ has a pre-processor).
> >>
> >>So my guess is that core/utils/src/rootcint_tmp is built/linked
> >>incorrectly and can not start.
> >>
> >>Cheers,
> >>Philippe.
> >>
> >>-----Original Message-----
> >>From: owner-roottalk_at_root.cern.ch
> >>[mailto:owner-roottalk_at_root.cern.ch] On
> >>Behalf Of Konstantin Olchanski
> >>Sent: Monday, March 01, 2010 2:12 PM
> >>To: Vassili Maroussov
> >>Cc: roottalk_at_lxbuild091.cern.ch
> >>Subject: Re: [ROOT] Cross-compiling on Fedora 12
> >>
> >>On Sat, Feb 27, 2010 at 01:03:27PM +0100, Vassili Maroussov wrote:
> >>
> >>>Generating dictionary core/meta/src/G__TCint.cxx...
> >>>core/utils/src/rootcint_tmp -cint -f core/meta/src/G__TCint.cxx -c
> >>>-DG__API core/meta/inc/TCint.h core/meta/inc/LinkDef_TCint.h
> >>>/usr/bin/ld: i386:x86-64 architecture of input file
> >>>`/usr/lib/gcc/x86_64-redhat-linux/3.4.6/libfrtbegin.a(frtbegin.o)' is
> >>>incompatible with i386 output
> >>>/usr/bin/ld: final link failed: Invalid operation
> >>>collect2: ld returned 1 exit status
> >>>make: *** [bin/g2root] Error 1
> >>>
> >>
> >>Looks like "rootcint" is calling GCC without the "-m32" flag and
> >>"/usr/bin/ld"
> >>tries to link against the 64-bit runtime library (libfrtbegin.a).
> >>
> >>To be extra user friendly, it (rootcint or Makefile) hides the actual
> >>GCC
> >>command line,
> >>so it is hard to tell what it going on there.
> >>
> >>But perhaps I am confused - it looks as if "rootcint" generates the
> >>dictionary source
> >>file and immediately call GCC to compile it. That used to be 2 different
> >>steps
> >>in the Makefile and it was easy to add "-m32" to the right place to
> >>fix it.
> >>
> >>If rootcint invokes GCC directly, it should accept the "-m32/-m64"
> >>switch
> >>and pass
> >>it to GCC as we cannot read the user mind to tell how they want
> >>things to be
> >>compiled.
> >>
> >>
> >>
> >
>

> #include <TFile.h>
> #include <TNtuple.h>
> #include <TH2.h>
> #include <TRandom.h>
>
> int main()
> {
> TFile *hfile = new TFile("hsimple.root","RECREATE");
>
> // Create some histograms, a profile histogram and an ntuple
> TH1F *hpx = new TH1F("hpx","This is the px distribution",100,-4,4);
> TH2F *hpxpy = new TH2F("hpxpy","py vs px",40,-4,4,40,-4,4);
> TNtuple *ntuple = new TNtuple("ntuple","Demo ntuple","px:py:pz:random:i");
>
> TRandom r;
> Float_t px, py, pz;
> for (Int_t i = 0; i < 25000; i++) {
> r.Rannor(px,py);
> pz = px*px + py*py;
> Float_t random = r.Rndm(1);
> hpx->Fill(px);
> hpxpy->Fill(px,py);
> ntuple->Fill(px,py,pz,random,i);
> }
> hfile->Write();
> }

-- 
Konstantin Olchanski
Data Acquisition Systems: The Bytes Must Flow!
Email: olchansk-at-triumf-dot-ca
Snail mail: 4004 Wesbrook Mall, TRIUMF, Vancouver, B.C., V6T 2A3, Canada
Received on Wed Mar 03 2010 - 20:23:42 CET

This archive was generated by hypermail 2.2.0 : Wed Mar 03 2010 - 23:50:01 CET