These pages assume that you have Microsoft
Visual C++ .NET, ROOT sources and cygwin installed. If you don't have ROOT or
cygwin: download them - they're free. If you don't have MSVC.NET, use the cygwin gcc build target for ROOT.
Download the current ROOT sources (not the binaries!). If you want the current, state-of-the-art version you can run cvs up from within the ROOT source directory. The cleaner the ROOT installation is (i.e. if you didn't run make yet, or did a make distclean before starting with these instructions) the cleaner your automatically generated project files are going to be. Nevertheless, the ROOT sources have to be configured first! To do that, start a cygwin bash shell, cd "`cygpath "$ROOTSYS"`" and run e.g. ./configure win32gdk --build=debug. For the first steps on setting up cygwin and ROOT's sources see the ROOT build documentation. You should then have %ROOTSYS% (or $ROOTSYS in the cygwin world) and %PATH% ($PATH) set up properly, and your ROOT sources should be unpacked and configured.
|Create the Build Script||To be able to build ROOT with a single command (issued by MSVC.NET) you will need a build script. This first part offers you such a script for downloading and tells you how to install it.|
|Create MSVC Solution||Before building anything you'll have to create a solution (formerly known as "workspace"). This part explains what and how.|
|Populate the Project File||The default project file created with the solution is empty. I will explain how to put the ROOT source files into the project file, mirroring the ROOT directory structure for easy file access.|
|Browser Info: Introducing ROOT classes to MSVC||Now we can build ROOT. But for a proper IDE we want auto-completion. To get that we need to build MSVC's browser info file. This part explains how to do that.|
|Tweaking MSVC's debugger||You can tell MSVC's debugger what to display, e.g. in the watch window, when coming across a TNamed. I'll show you how.|
|Create the Build Script|
MSVC.NET needs one single command to execute to build and clean the sources. As ROOT's build system for Windows uses cygwin's bash, we need to wrap all that into one script. This is what the script looks like:
@rem --- ROOT BUILD SCRIPT --- @rem Customize CYGWINROOT to point to your cygwin installation's root directory @set CYGWINROOT=C:\cygwin @call %VSCOMNTOOLS%vsvars32.bat @%CYGWINROOT%\bin\bash --login -c 'cd $ROOTSYS ; make %1'
For the following sections I assume you have saved this file as C:\root\buildroot.bat - but that's arbitrary.
|Create MSVC Solution|
Now you have a MSVC ROOT project file - but it's empty. We will tell MSVC about ROOT's sources (and how to build them) in the next part.
|Populate the Project File|
First of all: Close Microsoft Visual C++ .NET (say Yes when asked
to save changes). Now download this file - a
script that will create a filled ROOTmakefile.proj. Save it somewhere,
say under C:\root\createRootProj.sh.
Now open a cygwin bash shell. cd to wherever the MSVC project was stored at (something like "C:\documents and settings\username\my documents\...") (e.g. by opening an Explorer window, clicking around until you find the directory containing the project file, copying the path name from the address bar, pasting it into the cygwin bash shell and prepending cd "`cygpath " and appending "´" ).
Run the createRootProj.sh script with the location of the above buildroot.bat script as parameter (if necessary, i.e. if the path has spaces, surround it by ""), in the example by typing /cygdrive/c/root/createRootProj.sh /cygdrive/c/root/buildroot.bat
You can now start MSVC .NET, selecting the solution you created above - and after a while (MSVC needs a while to parse its project file) you will see a directory tree resembling ROOT's directory structure, filled will ROOT's sources, headers and utility files. Not all of these files are used for building root under win32 - but I find it nice to have them available nevertheless.
|Browser Info: Introducing ROOT classes to MSVC|
Before hitting F7 to (re)build ROOT, it's a perfect occasion to change some
settings that allow MSVC .NET to help you writing code. For MSVC .NET to gain
knowledge about all of ROOT's classes and methods it needs a browser
file. We will add this file (in a very crude way) to the build targets.
For example in MSVC .NET, open %ROOTSYS%\MyConfig.mk (which is, most probably, a new file). Add the lines
CXXFLAGS += /FR CFLAGS += /FROpen %ROOTSYS%\MyRules.mk (again most probably a new file). Add the lines
ALLEXECS += root.bsc root.bsc: $(shell ls *.sbr) BSCMAKE /o$@ *.sbr
The first will tell MSVC to create .sbr-files (in %ROOTSYS%) containing source browser information, the latter is an ugly hack that will tell the build system to combine these files into one big root.bsc containing all relevant source browser information. You might get some warnings when building the browser info file (such as "too many references"). Ignore them - MSVC has a limit on what it can handle, and apparently ROOT is beyond that limit...
MSVC should now automatically find this browser info file and offer code completion, jumping to definitions of classes and methods etc.
|Tweaking MSVC's debugger|
Visual C++ shows values of e.g. locals variables in the "watch" window. To show the contents of members, you can click on the little '+' in front of a variable, and it will be expanded. But wouldn't it be nice to see the essential values of an object before clicking the plus? Like MSVC does it for std::lists, showing their size? Let's assume you want to have MSVC displaying the name and title for TNamed:
Open the text file C:\Program Files\Microsoft Visual Studio .NET\Common7\Packages\Debugger\autoexp.dat (or wherever you have installed MSVC, if you don't find it then search for the file). To show the content of a TString (which resides in its member fData), add the line TString= <fData>. So the syntax is TYPE=TEXT<MEMBER>. Now let's try to add the TNamed line: TNamed= name=<fName.fData> title=<fTitle.fData> As you can see, you can easily add multiple members into one line. Another important rule with these display settings: if MSVC doesn't find a given class in autoexp.dat, it will look for an entry for any base class, starting at the directly inherited class. This means after adding TNamed you will also see TH1F, TBranch etc displaying their name and title. Custom display settings might also be helpful for the collection classes (TCollection's size, TClonesArray's contained type), iterators, GUI classes or matrices. You'll come up with plenty of better visualizations than the pure address.
Page maintained by Axel Naumann. Last updated on 2003-04-28.