Compiling ROOT 6 executable on Windows

ROOT Version: 6.16/00
Platform: Windows 10
Compiler: cl.exe

With respect to the recent release of ROOT 6 for Windows. I want to give it a try and compile an MS Windows executable.

I’m familiar with ROOT and GNU Makefiles. On macOS and Linux the process is following:

  1. generate dictionary file with “rootcling” from headers and LinkDef.h
  2. compile shared library from sources and dictionary
  3. compile all source files
  4. link all object files and shared library into executable.

For a reference here is an example of ROOT’s GNU Makefile.

At a first glance NMAKE syntax looks quite similar to GNU Make. Are the above steps will be the same on Windows?

Also on macOS or linux I used root-config to obtain values for compiler flags, library search paths and ROOT shared libraries names:

CXXFLAGS=`root-config --cflags` -fPIC
LDFLAGS=`root-config --ldflags`
GLIBS=`root-config --glibs` -lRooFit -lRooFitCore -lHtml -lMinuit -lFumili

How do I obtain correspondent values for the Windows cl.exe compiler?


The steps are the same on Windows, but to obtain the compiler flags, there is no equivalent script for Windows. You can take a look at the $(ROOTSYS)/include/compiledata.h header file, it contains the compile/build informations. And to compile/build your application, you can use CMake, Visual Studio, Nmake makefiles, or simply cl.exe on the command prompt (passing the compiler flags). But if you’re not familiar with development on Windows, I’m afraid it will be a bit complicated…

Cheers, Bertrand.

Hi Bertrand, thanks for your answer.

I just checked the compiledata.h on Windows. At a first glance the #defines for shared library and executable look a little more sophisticated compared to linux/mac versions.

Actually on linux or mac I do use the exact same GNU Makefile for all my ROOT applications. It pulls sources/headers list via wildcards. So the only thing I have to change across Makefile is just the variable that stands for the program (executable) name.

Correct me if I’m wrong but since the build steps are the same on Windows then ROOT users could use the same generic Makefile (CMake, Nmake) for literally any ROOT program. Maybe with some minor changes required.

Is there a chance you guys can provide this makefile? That will save us tons of time.


You can look at the Makefile.win32 makefile as an example

Cheers, Bertrand.

Nice! Thanks Bertrand.

I’m developing a data analysis toolset for years now.
It uses Qtas a build system and we use it under windows (unfortunately only 32bit) and linux and it links against ROOT for Histograms, Graphs, data fitting etc.
It worked on both platforms nicely with ROOT5 and on linux with ROOT6.

On windows I’m struggling to update the information for ROOT6 needed to sucessfully link against the ROOT libraries.
The makefile linked in this thread and the root-config (which i got running with a Mingw shell) return the wrong list of libraries.

What I basically need (hopefully) is the updated information for the qmake project file, which should be similar to what every other build system needs:

-include:_G__cpp_setupG__Graf -include:_G__cpp_setupG__G3D
-include:_G__cpp_setupG__GPad -include:_G__cpp_setupG__Tree
-include:_G__cpp_setupG__Rint -include:_G__cpp_setupG__PostScript
-include:_G__cpp_setupG__Matrix -include:_G__cpp_setupG__Physics

$(ROOTSYS)\lib\libCint.lib $(ROOTSYS)\lib\libHist.lib
$(ROOTSYS)\lib\libGraf.lib $(ROOTSYS)\lib\libGraf3d.lib
$(ROOTSYS)\lib\libGpad.lib $(ROOTSYS)\lib\libTree.lib
$(ROOTSYS)\lib\libRint.lib $(ROOTSYS)\lib\libPostscript.lib
$(ROOTSYS)\lib\libMatrix.lib $(ROOTSYS)\lib\libPhysics.lib
$(ROOTSYS)\lib\libNet.lib $(ROOTSYS)\lib\libRIO.lib

Do I just need to list all the libs which are present/needed? How do I generate the list of the G__cpp_setupG_* entries?

Best regards,

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.