Re: Reading files from a root executable

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Fri, 18 Nov 2005 09:10:51 +0100 (MET)


Luca,

What is your file run800.ntp ? a ROOT file ? if yes, it does not make sense to read it this way.
If it is an ascii file, it must have the correct format and contain integer data.

Rene Brun

On Thu, 17 Nov 2005, Luca Grandi wrote:

> Hi I continue to get the following error
>
> luca$ ./lifetime
>
> *** Break *** segmentation violation
> Abort trap
>
> 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;
> FILE_ntp.open("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]);
> 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
>
> Thanks
> Luca
>
>
>
>
> # 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)
>
> PROGRAMS = $(LIFETIME)
>
> #---------------------------------------------------------------------------
> ---
>
> .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 Fri Nov 18 2005 - 09:10:56 MET

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