VS.NET Integration

 
Home Research Classes

CTBuild and VS.NET

The ctbuild files that are found in a d0cvs package can be translated into a VS.NET solution.

  • Download and Install the VS.NET 2005 Extensions (version 3.0.0 - 7/30/2006) - for VS.NET 2005 Only!!!
    • Every user must add the Helper Programs directory to the default set of executables:
      1. Start VS.NET, Tools -> Options
      2. Select Projects and Solutions -> VC++ Directories
      3. From the drop down menu, select Executable files.
      4. Add a new path. It will be similar to c:\Program Files\D0 CTBuilt VSNET Integration\Helper Programs.
    • As usual, make sure you've added the various root directories. One of these days I'll figure out how to automate this.
    • Sadly, it is not possible to use the VS.NET Express (free!) version of MS's compiler with these tools. The tools depend on a feature called addins, and that is disabled in the Express version.
  • Download and Install the VS.NET 2003 Extensions (version 2.0.1 - 11/14/2005) - for VS.NET 2003 Only!!!

NOTE: You only have to install once -- and if on a terminal server, just once as administrator (but make sure no one else is logged in at the time!).

Start a new DZERO Release

This is always the first thing you'll want to do when starting a new project.

  1. Create a new local release directory. Any old folder will do (I usually start with an empty folder).
    • WARNING: The path of this folder can't contain any spaces! ROOT especially can't deal with spaces in the filenames! And I'm afraid failure messages will not be pretty!
    • NOTE: If you are using the top machine then use the directory D:\users\<username> as your base.
  2. Download the cvs packages you think you need into this folder from d0cvs (or wherever).
  3. In VS.NET, File->New->Blank Solution. Then use the mouse to navigate to "Visual Studio Solutions" and select the DZERO release option.
  4. Make sure that the dialog box location field points to your local release directory. The name of the project will be ignored.
  5. Click OK. You'll get a new dialog box; you can just click ok.
  6. VS.NET will now scan the local release directory for all CTBuild packages and add a complete set of projects to your release.

At this point you can right click and build. You can run binaries as well. The working directory for the binaries will default to your local release directory.

Special Notes for CAF

As of version 2.0, these guys support correctly building sharable libraries and, thus, CAF. The .rootmap file is also properly generated so it is possible to run root and have it automatically import the classes required without you having to do any extra work. Here are the steps to follow:

  1. Check out caf_sam to your local release directory.
  2. Edit the caf_sam/src/COMPONENTS files and remove "SAMExpander". It would be best then to delete all SAMExander files from caf_sam (including the linkdef files) to make sure they aren't picked up. SAM Is not supported on windows! ;-)
  3. Follow steps 1-6 from above, but in step 4 make sure to click the sharable library option.
  4. Edit the cafe.cpp binary source file, and remove all references to the dont_use variable. This was added to force a linkage between libraries, but both isn't required on windows and doesn't work!

At some point you'll be checking out the cafe cvs package. The current versions of cafe use the header time.h in Timer.cpp -- time.h is not supported on Windows. We hope to have a fix for that soon.

Please note that CAF support isn't seemless, for a number of reasons. Please read the known issues at the bottom of the page (I'm working to make it better).

Add a New COMPONENT

To add a new C++ component to an existing library do the following:

  1. Right click on the library you want to add the component to.
  2. Select "Add" -> "Add New Item..."
  3. Find the D0 folder under the item list and select DZERO Component.
  4. Fill in the Name field near the bottom of the dialog and click Open.
  5. In the new dialog box that comes up make sure the class name is correct, and the relative directory where it should be stored (defaults to src, headers automatically put in the package name sub directory).
  6. Check Add Root Linkage if this object is expected to be a full blown ROOT class with meta data (i.e. root I/O knows about it).
  7. Click OK and all files will be added to the project, the COMPONENTS ctbuild file will be updated as well.

Add a New Binary

To add a new binary to an existing cvs package do the following steps:

  1. Right click on the solution in the VS.NET solution explorer.
  2. Select Add -> New Project.
  3. Drill down to Visual C++ Projects -> DO and select DZERO Binary.
  4. Fill in the Name field with the name of the binary you want to create. Click OK.
  5. In the dialog box that comes up make sure to set the package name. Check the binary name is appropriate, and finally the directory relative to the package root directory where the binary should be created.
  6. Click OK to create the binary and the new project. SUBDIRS and BINARIES files will be created or modified as required.

Build and Run a Component Test

Projects for COMPONENT tests are not automatically created. But it is fairly easy to create one:

  1. Select the source file in the solution explorer matching the component test you wish to build and run.
  2. Right click and select the Load In Component Test Project command.
  3. Make the new project your default startup project, build, and run, test, etc.

Load a New CVS Package

If you've just checked out a new CVS package into your local release, you can have the libraries and binaries for that package loaded into VS.NET by doing one of two things:

  1. Right click on the solution in the VS.NET solution explorer.
  2. Select Add -> New Project.
  3. Drill down to Visual C++ Projects -> DO and select DZERO CVS Package.
  4. Click OK.
  5. In the dialog box that pops up, select the package you wish to add, click OK.

or

  1. Right click on the solution in the VS.NET solution explorer.
  2. Click Scan for New Packages.

This will scan your local release for all cvs packages that aren't already part of the VS.NET solution.

Preferences

It is possible to alter things like the library model, disabled warnings, and also edit the master include file (a .hpp file that is included by the compiler before any other file is processed in the release) by changing preferences.

  1. Right click on the solution in the VS.NET solution explorer.
  2. Select Preferences.
  3. Make alterations, and click OK.
  4. Right click on the solution in VS.NET, and select "Rescan" -- and your changes will take effect.

The updated preferences are stored in a user-specific XML file that can be found in the Application Data\VSDZERO directory under the user's Documents and Settings folder (e.g. D:\Documents and Settings\gwatts\Application Data\VSDZERO). The CodePrefs.xml file can be copied to the All Users directory and that will be loaded system wide. The user_include.hpp can be changed to system_include.hpp and copied to the system directory and it will also be included.

VS.NET provides lots of ways to integrate a lot of what I've done into the IDE, I'm afraid I wasn't able to figure out more quickly how to do that integration. :-)

Build & Checkout

d0 packages tend to depend heavily on each other. This feature makes it easier for you to check out a single package, and then have VS.NET figure out what other packages need to be checked out.

  1. Check out the package that contains the executable (or library) you are interested in. Follow the above instructions.
  2. Make sure you have Kerberos installed, and you've acquired a ticket (otherwise you'll get all sorts of failures).
  3. Right click on the project you want to build, and select "Build and Checkout" (don't do the Async one; it is broken).
  4. Sit back and wait. The build system will repeatedly attempt to build that project. After each failure it will scan the error messages for missing include files; attempt to determine the package, and then checkout the head version of that package.

This feature is not well integrated with VS.NET -- there is no way to interrupt it. Sorry. It is often the case that small differences in the compilers means you'll have to make some minor code changes -- and you can restart the process if you like once you've fixed those problems up.

Known Issues

  • Your initial creation of a DZERO solution may present your with a dialog box asking if you want to overwrite the solution and project files. Select the overwrite option.
  • If you you execute a build&checkout and the output window is not visible you won't be able to see what is going on. Make sure it is visible first. The simplest way to do this is do a normal build on the project you want to do a build&checkout on.
    • This is fixed in the 3.0 version.
  • If you cvs update a package or otherwise alter it, none of the changes are automatically picked up by the IDE. You must right click on the library you've updated and select Rescan.
  • If you re-scan the project and some components or root components have been removed, they won't be removed from the IDE. You'll quickly find this when you do a build as it will be trying to do something with a non-existant file. Either delete them by hand, or delete the whole project and then select "scan for new projects" from the right-click solution explorer.
  • The compiler's preprocessor is used by rootcint. Unfortunately, if the preprocessor can't find an include file, it will fail, but rootcint will continue as if there was no problem at all. The result is MSVC doesn't realize rootcint needs to be rerun. You'll most likely see this when you do the automatic checkout. The only thing to do is recompile the affected linkdef files, or rebuild the whole project. You may see this problem manifest itself as missing Streamer methods. Just do the rebuilt at that point.
  • There is a bug in root in how it builds the .rootmap file. If you are building shared libraries and they reference objects with a namespace (like cafe), then after you've done the first build you should edit the .rootmap file, and add the following line:

    Library.cafe: C:\Physics\cafe\win\libcafe\Debug\libcafe.dll C:\Physics\cafe\win\libtmb_tree\Debug\libtmb_tree.dll C:\Physics\cafe\win\libmet_util\Debug\libmet_util.dll

    Make sure to fix up the paths for your local release. You'll find that most other lines in the .rootmap file look identical, except for the first part. Feel free to copy and modify them.

    • I've not encountered this bug in version 3.0 (against a modern version of root).
  • If you are running in a non-admin account, and have installed the extensions but not started VS.NET 2005 yet, you'll get an error. Click "no" to the error (i.e. don't try to move the addin out of the way), and once VS.NET starts, quit it, and start it again. Everything will be fine. This happens only in version 3.0. No clue why yet.

Version History

  • 2.0.1 (11/13/2005)
    • Revert project dependencies to old method for static builds. Otherwise modules were being included multiple times in libraries. This was causing lots (100's of thousands) of link warnings about multiply defined symbols.
  • 2.0 (11/13/2005)
    • Support for sharable libraries built for ROOT. Targeted for building CAF executables.
    • The rootcint preprocessor was switched to use cl's preprocessor rather than the built in one in root.
    • It is possible to specify a release, and automatic checkouts will now be tagged by that release. This requires access to the web (www-d0 has package lists on it that these tools access).
    • asinh is now defined.
  • 1.2 (11/6/2005) - It is possible to create a component test project, build, and run it.
  • 1.0 - Original version.