Reading files from a root executable

From: Luca Grandi <>
Date: Thu, 17 Nov 2005 19:18:03 +0100

Hi I continue to get the following error

luca$ ./lifetime

in executing the executable called lifetime. Its source is as it follows and it is compiled to run outside root.

#include <iostream>
#include "TFile.h"
#include "stdio.h"
#include "stdarg.h"
#include <fstream>
#include "Riostream.h"

int main()

    Int_t nlines=0;

    Int_t n_run[10000000], n_ev[10000000];     ifstream FILE_ntp;"run800.ntp");
    while (1){
    if (!FILE_ntp.good()) {break; printf("ERRORE\n");}

      FILE_ntp >> n_run[nlines];
      if (nlines<5) printf("%d\n",n_ev[nlines]);


To create the executable I have used the makefile attached at the end of the mail: in the same directory I have the standard Makefile.Arch file. Compiling it under OSX gives me the output

c++ -O2 -pipe -Wall -W -Woverloaded-virtual -D_REENTRANT -Wno-long-double -I/sw/include/root -c lifetime.cxx
MACOSX_DEPLOYMENT_TARGET=10.4 c++ -O2 -bind_at_load lifetime.o

-L/sw/lib/root -lCore -lCint -lHist -lGraf -lGraf3d -lGpad -lTree -lRint
-lPostscript -lMatrix -lPhysics -L/usr/X11R6/lib -lfreetype -lpthread -lm
-ldl  -o lifetime

lifetime done
MACOSX_DEPLOYMENT_TARGET=10.4 c++ -dynamiclib -single_module -undefined dynamic_lookup -o
make: *** [all] Abort trap

WHAT IS the problem? I have written other small programs and I get the same error each time I Try to read a file (for example with scanf) while I have no problem to write on files. Note that they are working properly if executed as a script in root


# Makefile for the ROOT test programs.
# This Makefile shows nicely how to compile and link applications
# using the ROOT libraries on all supported platforms.
# Copyright (c) 2000 Rene Brun and Fons Rademakers
# Author: Fons Rademakers, 29/2/2000

include Makefile.arch



LIFETIMEO       = lifetime.$(ObjSuf)
LIFETIMES       = lifetime.$(SrcSuf)
LIFETIME       = lifetime$(ExeSuf)

OBJS          = $(LIFETIMEO)


--- .SUFFIXES: .$(SrcSuf) .$(ObjSuf) .$(DllSuf) all: $(PROGRAMS) ifeq ($(PLATFORM),macosx)
# We need to make both the .dylib and the .so
$(LD) $(SOFLAGS) $(EVENTO) $(OutPutOpt) $(EVENTSO) $(LD) -bundle -undefined $(UNDEFOPT) $(LDFLAGS) $^ \ $(OutPutOpt) $(subst .$(DllSuf),.so,$@) endif @echo "$@ done" $(LIFETIME): $(LIFETIMEO) $(LD) $(LDFLAGS) $^ $(LIBS) $(OutPutOpt)$@ @echo "$@ done" clean: @rm -f $(OBJS) core .SUFFIXES: .$(SrcSuf)
.$(SrcSuf).$(ObjSuf): $(CXX) $(CXXFLAGS) -c $<
Received on Thu Nov 17 2005 - 19:18:11 MET

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:13 MET