When I started using ROOT, I tried to setup it up with Visual Studio because that’s what I’m familiar with. It took some effort to dig through this very forum but I finally got the setup I wanted. I was suggested that I should share the template of what I have of here I am.
What it is:
Visual Studio 2013 template for creating a simple ROOT applications. You can of course compile and run it but (as long as you respect CINT’s limitation) can also run as ROOT macro. The different between main() and macroname() entry point is taken care of in the code template. The Intellisense and all the usual jazz work as expected.
- Install ROOT release build somewhere.
1a. (optional) Download ROOT debug build tarball and extract it somewhere else.
- Make sure you have Environment Variable “ROOTSYS” that pointed to the ROOT release build folder e.g. C:\root.
2a (optional). Make sure you have “ROOTSYSD” (note the “D”) pointed to ROOT debug build folder.
- Place the attached zip file in <Visual Studio 2013 Project folder>\Templates\ProjectTemplates\Visual C++ Project e.g. “Documents\Visual Studio 2013\Templates\ProjectTemplates\Visual C++ Project”. No need to extract the zip.
- Create new project using “RootTemplate” in Visual C++ project type. The project name will be the name of your macro.
- Code your stuffs in run(). Debug as usual.
I think with new installer for ROOT (~5.34/20+), you may need to make sure you have PATH=C:\root\bin in Environment Variables as well since it’s not added by default anymore.
- No dictionary generation. Search on this forum on how to add this to “Pre-build”. I’m not quite happy with that because the project will get recompiled even if the main code does not change due to “new” dictionary.
- You cannot use parameters when calling as macro. I usually don’t use macro mode so I’m less motivated to work on that.
- Some ROOT version seems to give trouble when run in debug configuration. The newest one seems to be ok. If changing the version is not an option, I suggested having ROOTSYSD pointed to the ROOT release built. You should still be able to step through/watch your own code.
Should work with any ROOT5 version, but I’ve tested it with 5.34/18-26 as of this writing. Obviously, ROOT6 won’t work.
This is more for a quick ROOT program/macro, as I designed this as a starting point for my physics analysis code. If you need a more sophisticated ROOT usage, I suggested checking out Gordon Watt’s github.com/gordonwatts/ROOTPackageBuilders
Hope it is useful for someone. Feedback are welcomed, but I can’t promise I’ll have time to work on it…
PS. Please ignore the “Makefile”. It’s my attempt to make a configuration that automatically upload the macro and run it on a Linux machine. It somewhat works, but very messy. I’ve deleted the configuration but simply too lazy to delete the file.
RootTemplate.zip (31.1 KB)