I’m currently using the ROOT libraries as part of a console app on Windows XP, with Visual Studio.NET 2003 as my compiler. I’ve got some code that compiles correctly, and is supposed to display some histograms on the screen as well as saving them to postscript files.
The problem I have is this: The program appears to be running correctly, with the exception that it doesn’t display any of the canvases on the screen. It correctly prints them to the postscript files, so as far as I can tell the progam is running properly in every other respect.
The chunk of code I am using to display the histograms works fine when used in a macro from within CINT, so I am at a bit of a loss to understand why it doesn’t work when I compile the code. For example, this works fine from within CINT:
I notice from page 6 of the root manual that all of the graphics-dependent libraries that I have included say things like:
“libGpad.lib is the pad and canvas classes which depend on low level graphics”
What are these “low level graphics”, and how do I get them to operate within VS.net 2003? Could this be the reason that I am not getting any graphical output from ROOT? I can’t think of anything else that could be causing this problem.
Could you send the shortest possible script reproducing your problem?
When you execute root at the command line, do you see teh splash screen?
When inside root and typing the following command
root > TCanvas c
do you see a graphics window?
In case you see a graphics window with your application, but an empty
canvas, are you sure that your C++ objects are not deleted (going out of scope) when the function returns?
In response to Rene, the object that contains my histograms is defintely not going out of scope, so it is not that. I can’t really offer you a script to reproduce the problem, since i’m not using CINT but am compiling my code. However, the code i’m using to make & display my plots works fine when in a macro, just not when compiled.
In response to Bertrand, I have VC++ 7.1 set up according to Francois-Xavier Gentit’s web site (slac.stanford.edu/~gentit/cas/XPDebug.html), and have tried adding the libraries you suggested (I can’t find libfreetype.lib in that directory). It appears to make no difference at all.
Any more suggestions? Do either of you commonly use VC++ 7.1? When you make a Win32 Console App with ROOT libraries, I take it you don’t suffer these problems?
You must create a TApplication in order to have Root processing events ( within theApp.Run() )
Take a look into $(ROOTSYS)/test directory, there are samples.
Right, your code makes everything work properly. However, I was presuming that when the user closed all the canvas windows theApp.Run() would then terminate its infinite loop and return control to the console window. It doesn’t do this - is there a way around this? At the moment I have to use ctrl-c to exit the program.
To exit Root, you have to select “Quit Root” from the menu “File” of the canvas.
You can also make your own TCanvas derivated class, and call gApplication->Terminate() in CloseWindow().
Or to manually keep a list of opened canvases, and calling gApplication->Terminate() when count is down to zero.