Changing ROOT install

I just recently purchased a new Macbook Pro (64bit Snow Leopard), and have ROOT installed. I use ROOT as libraries in my C++/Fortran (both) code, which I compile via a makefile and gcc and gfortran.

However, I recently found out that gcc 4.2 has a bug with reading in from files, and none of the fixes I could find worked in my code. The one option I can think of left to try is to compile my code with gcc-4.0 (which I have installed, and it seems to work on my old laptop under 4.0).

When I try to compile my code with gcc-4.0, I get an error message about how ROOT was compiled with 4.2.1, and they aren’t compatible.

Can someone provide info on how to remove my previous install of ROOT and then install it using gcc-4.0? I only know how to install it following the instructions, and have no idea how to use the non-default compiler.

Thanks in advance.
~Travis Martin

Okay, I have done some testing today and I don’t think the same as I did before regarding this issue.

I have been able to compile some straight C++ code with 4.2.1 just fine. BUT, as soon as I include ROOT libraries, that is when my code crashes on run. It compiles without errors but it crashes when I execute it.

I compiled ROOT from source following the instructions included.

Hi,

Can you provide a running example showing the problem (i.e. I compile and run ROOT with gcc 4.2.1 on Mac without problems)?

Also do compile ROOT with an alternative version of g++, it should be sufficient to make sure that the location of the alternative version is early on the PATH and LD_LIBRARY_PATH.

Cheers,
Philippe.

In my usr/bin directory I have the following executables:
gcc
gcc-4.0
gcc-4.2

So changing my path wouldn’t have helped. Instead, I changed gcc-4.0 to gcc (made a backup of gcc first).

Then I compiled ROOT in a new directory and changed my .bashrc file to change the directory for ROOT.

Now, when I run my code, I get the following errors:
ld: warning: in /usr/local/lib/libgfortran.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
ld: warning: in /Users/mactop/root4/lib/libCore.so, file was built for unsupported file format which is not the architecture being linked (i386)
ld: warning: in /Users/mactop/root4/lib/libCint.so, file was built for unsupported file format which is not the architecture being linked (i386)
ld: warning: in /Users/mactop/root4/lib/libRIO.so, file was built for unsupported file format which is not the architecture being linked (i386)

and then a massive list of Undefined Symbols:
Undefined symbols:
“std::basic_string<char, std::char_traits, std::allocator >::find_first_not_of(char const*, unsigned long) const”, referenced from:
_main in zp_lhe.o
_main in zp_lhe.o
_main in zp_lhe.o
(etc)

So that didn’t work.

So I switched everything back to the way it was before, and I get the following when I try to run my code:

g++ -o zp_lhe.exe -O -lgfortran zp_lhe.o corr.o zpsigma.o pdf.o print.o psgen.o Cteq6Pdf-2004.o plots.o gsigma.o -L/Users/mactop/root4/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lfreetype -pthread -Wl,-rpath,/Users/mactop/root4/lib -lm -ldl -L/usr/local/lib
bash-3.2$ run_zp_lhe
zp_lhe.exe(54560) malloc: *** error for object 0x7fff7060d500: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
./run_zp_lhe: line 1: 54560 Abort trap /Users/mactop/Documents/Research/Programs/zp_lhe_2/zp_lhe.exe

But when I take out all of the ROOT components of my code, it compiles and runs just fine.

Thanks for the help so far. I hope this is what you were looking for.

Hi,

can you run stress from ROOTSYS/test? Does that work?

You might simply have a bug in your code (the part that involved ROOT). If you post your code we might be able to help you.

Cheers, Axel.

It might be a bug in my code, sure. But I had the exact same code working on my previous computer (Leopard, 32bit, GCC 4.0). And I can’t even include libraries in my C++ files, much less use any features of ROOT.

But you do bring up a good point. If ROOT has changed in the last few years since I last installed, that might be part of the problem. I hadn’t thought of that.


  • Starting R O O T - S T R E S S test suite with 1000 events

Test 1 : Functions, Random Numbers, Histogram Fits… OK
Test 2 : Check size & compression factor of a Root file… OK
Test 3 : Purge, Reuse of gaps in TFile… OK
Test 4 : Test of 2-d histograms, functions, 2-d fits… OK
Test 5 : Test graphics & Postscript… OK
Test 6 : Test subdirectories in a Root file… OK
Test 7 : TNtuple, selections, TCut, TCutG, TEventList… OK
Test 8 : Trees split and compression modes… OK
Test 9 : Analyze Event.root file of stress 8… OK
Test 10 : Create 10 files starting from Event.root… OK
Test 11 : Test chains of Trees using the 10 files… OK
Test 12 : Compare histograms of test 9 and 11… OK
Test 13 : Test merging files of a chain… OK
Test 14 : Check correct rebuilt of Event.root in test 13… OK
Test 15 : Divert Tree branches to separate files… OK
Test 16 : CINT test (3 nested loops) with LHCb trigger… OK



stress : Total I/O = 549.8 Mbytes, I = 406.3, O = 143.5
stress : Compr I/O = 387.9 Mbytes, I = 284.7, O = 103.2
stress : Real Time = 24.41 seconds Cpu Time = 20.82 seconds


  • ROOTMARKS =1783.3 * Root5.26/00 20091214/1543

So it looks like the stress test worked… Now I am confused…

I made a very simple code to try things out:

#include <iostream>
#include <cstdlib>
#include <string>
#include <cmath>
#include <vector>
#include <fstream>
#include <stdio.h>
#include <sstream>

using namespace std;

int main()
{
	cout << "Test" << endl;
	return 0;
}

Then I run in the terminal:
g++ -c test.cpp
g++ -o test test.o
./test

That works just fine.

Then I added this:

#include <iostream>
#include <cstdlib>
#include <string>
#include <cmath>
#include <vector>
#include <fstream>
#include <stdio.h>
#include <sstream>

[b]#include "TGraphErrors.h"
#include "TCanvas.h"
#include "TPad.h"
#include "TH1.h"
#include "TLegend.h"
#include "TColor.h"
[/b]
using namespace std;

int main()
{
	cout << "Test" << endl;
	return 0;
}

And I compile it with the makefile that links the libraries.

NAME	= test.exe

OBJECTS = $(NAME:.exe=.o) 

CPPFLAGS = -I/usr/local/include -I$(shell root-config --incdir)

ROOTLIBS = $(shell root-config --libs)

HEADERS = 

all:	$(NAME)

$(OBJECTS): $(HEADERS)

$(NAME): $(OBJECTS)
	g++ -o $(NAME) -O $(OBJECTS) $(ROOTLIBS) -L/usr/local/lib

.cpp.o:
	g++ -c -O $(CPPFLAGS) -I$(ROOTSYS)/include $*.cpp

And that is when it won’t run.

I never thought it might be the makefile and the code, since it does still run on my old laptop. Thanks again for the help and suggestions! Much appreciated!

[quote]ld: warning: in /Users/mactop/root4/lib/libCore.so, file was built for unsupported file format which is not the architecture being linked (i386)[/quote]I wonder if you have a build of ROOT for 64 bit (-m64) while you are attempting to build in 32 bits (-m32). I remember that in some version of gcc they changed the default (this may or may not be the problem). To clarify the situation you should make sure to always specify the one you want (-m32 or -m64) and making sure all the other library are built the same.

Cheers,
Philippe.

Maybe that is the problem.

Do I have to specify that when I am compiling ROOT? Or just when I am compiling my code.

I installed gfortran (from the High Performance Computing website, which has a bunch of installs for Macs). Will that also be an issue?

Thanks again!

Hi,

It looks like the fortran you downloaded is 64 bit and so (seemingly) is your ROOT, so all you need to do (if I am correct :wink:) is to add -m64 to your compilations.

Cheers,
Philippe.

When I compiled ROOT, I did configure with the option macosx64. So I assume I compiled it with 64 bit.

I just changed my makefile now to this:

NAME	= dsdm.exe

OBJECTS = $(NAME:.exe=.o) 

CPPFLAGS = -I/usr/local/include -I$(shell root-config --incdir)

ROOTLIBS = $(shell root-config --libs)

HEADERS = 

all:	$(NAME)

$(OBJECTS): $(HEADERS)

$(NAME): $(OBJECTS)
	g++ -o $(NAME) -m64 -O $(OBJECTS) $(ROOTLIBS) -L/usr/local/lib

.cpp.o:
	g++ -c -O -m64 $(CPPFLAGS) -I$(ROOTSYS)/include $*.cpp

It compiled fine, just as before, but it still gives me the same error as before. Am I missing something with the -m64 option?

I looked up the 64 bit option, and I found something that suggested using “-arch x86_64” instead. I tried that also and it didn’t make a difference.

To be honest, someone help me set up my makefile, so I don’t fully understand all the parts of it. Can someone explain what these are:

CPPFLAGS = -I/usr/local/include -I$(shell root-config --incdir)

ROOTLIBS = $(shell root-config --libs)

I only assume that those are correct. When I try “echo $(shell root-config --libs)”, it gives me an error. But I can do “echo $ROOTSYS” and it tells me the correct path.

Is $ROOTSYS/bin on you PATH ?

Philippe.

Yes, it is.

Here is my path setup:
export PATH=./:$ROOTSYS/bin:$PATH
export ROOTSYS=~/root
export LD_LIBRARY_PATH=$ROOTSYS/lib:$LD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$ROOTSYS/lib:$DYLD_LIBRARY_PATH
export PATH=/cern/pro/bin:$PATH

I googled some of the things I didn’t understand and came across some RootTalk correspondences between yourself and other people. It really helped understand it better.

Hi,

In the setup you show, ROOTSYS is used before being defined resulting in the PATH being wrong. Try: export ROOTSYS=~/root export PATH=./:$ROOTSYS/bin:$PATH export LD_LIBRARY_PATH=$ROOTSYS/lib:$LD_LIBRARY_PATH export DYLD_LIBRARY_PATH=$ROOTSYS/lib:$DYLD_LIBRARY_PATH export PATH=/cern/pro/bin:$PATH

Cheers,
Philippe.

PS. Note that in newer version of ROOT the first 4 lines can be simply replaced with