Drawing a histogram in a standalone binary

I am attempting to make a histogram program work, but I believe I am missing something extremely basic. In the following code, the bins are incremented corrrectly (I hope. When I but in other code to incrmement other variables, they are incremented correctly), but when I run the program, no histogram pops up. I compiled the program as a separate binary using “g++ -o histo -O0 -I./include -L./lib -lHist -lCore -lMatrix -lCint ./histo.cpp” on Mac OS X 10.4.1 using ROOT 4.04/02 and X11 4.4.0. Would it be easier to get this to run directly in ROOT? I tried many things, but couldn’t get the code to execute properly, possibly because of the external headers it uses, and also because I couldnt figure out how to get it to accept command line inputs (the file to be analyzed). Preferably though, I’d like to get the standalone binary working.

Thanks
[size=84]

#include <stdlib.h>
#include “qneteventlist.h”
#include “TROOT.h”
#include “TRint.h”
#include “TH1F.h”

using namespace std;
int main(int argc, char *argv[]){
TH1F *hfix = new TH1F(“hfix”,“hfix title”,52,0,2080);
qneteventlist mylist(argc,argv);

while(!mylist.End()){
int bad = mylist.GetNextEvent();
if(!bad & (mylist.CurrentEvent.fall[0]-mylist.CurrentEvent.rise[0]) > 0){
int diff=(mylist.CurrentEvent.fall[0]-mylist.CurrentEvent.rise[0]);
hfix->Fill(diff);
}
}

hfix->Draw();
cout <<“bobo”;
return 0;
}
[/size]

Hi,
you need a TApplication object. Read the User’s Guide p339-340.
Cheers, Axel.

After adding a header file and the TApplication object almost exactly as in the example, everything compiles fine. However, upon running, I get the following error:

[size=84]dlopen error: dlopen(/Users/captbob/Desktop/root/lib/libGX11TTF.so, 9): Symbol not found: __ZN3TTF11fgRotMatrixE
Referenced from: /Users/captbob/Desktop/root/lib/libGX11TTF.so
Expected in: dynamic lookup

Load Error: Failed to load Dynamic link library /Users/captbob/Desktop/root/lib/libGX11TTF.so[/size]

The library is there and I know of no reason why it should not be working. Anyone know what is going on?

Thanks

Your PATH variable does not include the ROOT libraries
or you forgot to link with the ROOT libraries. To see the list
of recommended libs when linking a graphics application run
root-config --glibs

Rene

I appended all of the libraries in there to the one I already had for [size=84]“g++ -o histo -O3 -I./include -L./lib -lHist -lCore -lMatrix -lCint -lGX11TTF -lCore -lCint -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lfreetype -lGui -lpthread -lm -ldl ./histo.cpp”[/size]

I then still got an error message ( a little diffferent):
[size=84]
dyld: Symbol not found: __ZThn68_N5TGX1113SetMarkerSizeEf
Referenced from: /Users/captbob/Desktop/root/lib/libGX11TTF.dylib
Expected in: dynamic lookup

Trace/BPT trap
[/size]

My DYLD_LIBRARY_PATH and other variables are all set correctly. Perhaps I am missing another library? It compiled and linked fine however.

Hi,

taking your code (commenting out the qnetevent code), compiling it using:

g++ root-config --cflags --glibs -o bobo bobo.cxx

works fine, popping up the histogram. This is on Tiger 10.4.2 using ROOT v5, but it should also work with ROOT v4 (if compiled on Tiger with gcc 4).

Cheers, Fons.

Adding in my includes, I as well got it to pop up (thought the data is mysteriously missing). This should be easily solved though on my end.

Thanks