How to compile a c++ file on windows 10 using root and Makefile?

Please read tips for efficient and successful posting and posting code

ROOT Version: 6.24.00
Platform: Windows 10
Compiler: Not Provided

i am totally new with using Windows 10 (but i am familiar with g++,root on linux). I need to compile on windows 10 a c++ project with a Makefile coming from linux. On windows 10 Pro, i succeeded to install root 6.24 and visual studio 2019, but now i am wandering how to proceed.

As a first test, i would like to compile this simple example that creates a simple TCanvas:
Can someone explain me the steps how to proceed please?

Frédéric Faure.

find ${ROOTSYS}/test -name "[mM]akefile*" # note: the "test" directory is provided in the source code distribution


Thanks for the answer,
but at that moment, this is not clear for me what it means?
Is it for Windows?
Is it some command that i have to write somewhere?

man find

Thanks, but sorry i was not clear. This is not on linux but on windows. as i said i am familiar with linux but totally new with windows that seems different, so i am just asking for simple but precise helps, if possible, on “how to compile a root project with Makefile on windows 10”. A kind of step by step help, just for starting. Thanks.

As said above, try the ROOT’s test examples.

Thanks, so i try to do this:

  1. i download root
  2. Following INSTALL, I open a command window, and do:
cd Downloads
mkdir builddir
cd builddir
cmake ../root

At that point i get the error message: “directory root does not exists”.
Indeed there is no directory called root it is called root-master (may be this is a typo in INSTALL), so i do instead:
cmake ../root-master
After few lines there is the following error:

So following this post i do instead:
cmake ../root-master -Dclad=OFF
and everything seems to be done correctly. Is it a typo in INSTALL?
Then i do:
cmake --build .
It works. The next step is execute
as explained here
(but not said in the INSTALL file)
The next step is: 4) try running root:
But there is no such binary file??
So i skip this, and try to compile the test programs:
I open a terminal called: “developer command prompt VS 2019”, and in the directory of test , i write:
It gives this error:

For the moment, i find very difficult to use root on windows 10. But i have still hopes… If someone can help me please?

In the “command prompt”, you probably need:

cd \...\test
nmake /f Makefile.win32

The command nmake /f Makefile.win32 gives:

Makefile.win32(66) : fatal error U1052: fichier 'win32.mak' introuvable

I found in this post that win32.mak is provided by Windows SDK. So i have installed windows SDK and re-installed Visual Studio so that he may find win32.mak. But still i have the same error. Somebody has an idea?

PS: My computer is a recent XPS13 (64 bits), so i am surprised to need win32. I am using Windows 10 on a virtual machine under ubuntu 20.04: virt-manager KVM as explained here. My objective is to export some c++ project that uses root from linux, to the Windows 10 platform.

I don’t use Windows myself (all I remember was once valid for ROOT 5, which was indeed a 32-bit x86 application).

You can use CMake, or you can compile in the command prompt, for example:

cl -nologo -O2 -MD -GR -EHsc -I%ROOTSYS%\include mysource.cxx /link -LIBPATH:%ROOTSYS%\lib libCore.lib libGui.lib libGpad.lib libHist.lib libTree.lib libGraf.lib /out:myapplication.exe 

or change the following lines in Makefile.win32:

!if ([nmake /? 2>&1 | findstr /c:"Version 11\." > nul ] == 0) || \
    ([nmake /? 2>&1 | findstr /c:"Version 12\." > nul ] == 0)
APPVER    = 5.01
cc        = cl
link      = link
implib    = lib
lflags    = $(lflags) /INCREMENTAL:NO /NOLOGO
conlflags = $(lflags) -subsystem:console
guilflags = $(lflags) -subsystem:windows
dlllflags = $(lflags) -entry:_DllMainCRTStartup$(DLLENTRY) -dll
!include <win32.mak>


APPVER    = 5.01
cc        = cl
link      = link
implib    = lib
lflags    = $(lflags) /INCREMENTAL:NO /NOLOGO
conlflags = $(lflags) -subsystem:console
guilflags = $(lflags) -subsystem:windows
dlllflags = $(lflags) -entry:_DllMainCRTStartup$(DLLENTRY) -dll

@bellenot Can you fix all Makefile.win32 files (and the Makefile.arch, if needed) in the official source code repository?

Actually, they should be “.win64” now, or may better “.mvc”. Keeping “.win32” may be misleading.

Update: The 23rd post here says that ROOT 6 is still a 32-bit x86 application (even on 64-bit Windows), so “.win32” is “mandatory”.

Will do, once back at work (next month). And win32.mak is obsolete

Hello, thanks for the information.
So i tried to compile hsimple.cxx or guitest.cxx like this:

The error is a missing librairy. So i checked which librairies are in directory lib:

So it seems that many lib are missing here? Do you have an idea?

How did you install ROOT?

What i did from the begining:

  1. On ubuntu 20.04: i installed Windows 10 Pro on a virtual machine virt-manager KVM as explained here
  2. On this windows 10 virtual machine, i installed Visual Studio community and CMake and Windows SDK and GitHub.
  3. From github, i downloaded root
  4. I followed more or less the file INSTALL and did in the directory root-master:
mkdir build2
cd build2
cmake ../root-master -Dclad=OFF
cmake --build .

Then the previous message shows what i did in the directory test.

Why -Dclad=OFF? Here is the correct configuration:

cmake -G"Visual Studio 16 2019" -A Win32 -Thost=x64 -DCMAKE_VERBOSE_MAKEFILE=ON ../root-master 

This is not enough. On Windows you must specify the configuration (e.g. Debug or Release):

cmake --build . --config Release

And make sure you run in a x86 Native Tools Command Prompt for VS 2019.
Please try again and check if there is any error message at the end of the build

@bellenot Why are these MANDATORY additional flags missing in the official instructions on the “Installing ROOT” and “Building ROOT from source” web pages?

Well, you’re right, the Windows specific part is missing…

There is one thing that I don’t understand now. Is ROOT 6 built with MVC on Windows still only a 32-bit x86 application, or can it be built as a proper 64-bit x86_64 one?

BTW. The "-Dclad=OFF is a result of an error shown in the 7th post here. Maybe you know how to fix it.