[ROOT 6.34] Windows Compilation: w32pragma issue [CEA 43597]


ROOT Version: 6.34.02
Platform: win64 (Windows 10)
Compiler: MSVC 19.39


Dear ROOT Developers,

TL;DR

I would like to compile a simple C++ program on Windows 10 with Visual Studio 2022 & ROOT 6.34.

MWE

Here is the minimal example:
test.cpp (177 Bytes):

#include "TF1.h"
#include <iostream>

int main() {
    TF1 function("identity", "x");
    std::cout << "evaluation: " << function.Eval(1.) << std::endl;
    return 0;
}

Environment

I loaded the development environment like this:

PS C:\URANIE\43597> Push-Location
PS C:\URANIE\43597> & "C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/Tools/Launch-VsDevShell.ps1" -Arch amd64
**********************************************************************
** Visual Studio 2022 Developer PowerShell v17.3.6
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
PS C:\Users\sc774194\source\repos> Pop-Location
PS C:\URANIE\43597>

Building

ROOT 6.34

And I compiled the minimal example:

ROOT Version:

PS C:\URANIE\43597> root -q
   ------------------------------------------------------------------
  | Welcome to ROOT 6.34.02                        https://root.cern |
  | (c) 1995-2024, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for win64 on Dec 15 2024, 07:44:28                         |
  | From tags/v6-34-02@v6-34-02                                      |
  | With MSVC 19.39.33521.0                                          |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'  |
   ------------------------------------------------------------------


PS C:\URANIE\43597>

Flags:

PS C:\URANIE\43597> root-config --cflags
-nologo  -Zc:__cplusplus -std:c++17 -GR -FIw32pragma.h -FIsehmap.h -MD -EHsc -wd4141 -wd4291 -wd4244 -wd4049 -wd4146 -wd4250 -wd4624 -wd4267 -D_XKEYCHECK_H -DNOMINMAX -D_CRT_SECURE_NO_WARNINGS -D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING -D_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING  -O2 -IC:\URANIE\43597\root_v6.34.02.win64.python311.vc17\root\include
PS C:\URANIE\43597>

Compilation:

PS C:\URANIE\43597> Invoke-Expression "cl test.cpp $(root-config --cflags --libs)"
cl : Ligne de commande warning D9024 : type de fichier source non reconnu '.h', fichier objet pris par défaut
cl : Ligne de commande warning D9024 : type de fichier source non reconnu '.h', fichier objet pris par défaut
test.cpp
test.cpp: fatal error C1083: Impossible d'ouvrir le fichier include : 'w32pragma' : No such file or directory
PS C:\URANIE\43597>

How can I solve this file type / header issue?

ROOT 6.32

Here is a successful build with ROOT 6.32.

ROOT Version:

PS C:\URANIE\43597> root -q
   ------------------------------------------------------------------
  | Welcome to ROOT 6.32.08                        https://root.cern |
  | (c) 1995-2024, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for win64 on Nov 14 2024, 09:53:39                         |
  | From tags/v6-32-08@v6-32-08                                      |
  | With MSVC 19.39.33521.0                                          |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'  |
   ------------------------------------------------------------------


PS C:\URANIE\43597>

Flags:

PS C:\URANIE\43597> root-config --cflags
 -nologo -Zc:__cplusplus -std:c++17 -MD -GR -EHsc- -W3 -D_WIN32 -O2 -IC:\URANIE\43597\root_v6.32.08.win64.vc17\root\include
PS C:\URANIE\43597>

Compilation:

PS C:\URANIE\43597> Invoke-Expression "cl test.cpp $(root-config --cflags --libs)"
test.cpp
PS C:\URANIE\43597> .\test.exe
evaluation: 1
PS C:\URANIE\43597>

Best Regards,

Thanks for reporting, we’ll check

It looks like an issue with PowerShell who doesn’t like the -FIw32pragma.h option.

EDIT: I’ll have to make a specific root-config.ps1, or add quotes around -FIw32pragma.h -FIsehmap.h, like -FI"w32pragma.h" -FI"sehmap.h". Can you try to edit the ${ROOTSYS}\bin\root-config.bat script and add the double quotes at around line 48, as following:

set cxxflags=-nologo  -Zc:__cplusplus -std:c++17 -GR -FI"w32pragma.h" -FI"sehmap.h" -MD -EHsc -wd4141 -wd4291 -wd4244 -wd4049 -wd4146 -wd4250 -wd4624  -D_XKEYCHECK_H -DNOMINMAX -D_CRT_SECURE_NO_WARNINGS -D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING -D_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING 

And let me know if it works? (it works for me, and that would be the easiest solution)

1 Like

Thank you for your proposal.

I made the change you suggested:

PS C:\URANIE\43597> Compare-Object (Get-Content .\root-config.bat) (Get-Content ${ROOTSYS}\bin\root-config.bat)

InputObject
-----------
set cxxflags=-nologo  -Zc:__cplusplus -std:c++17 -GR -FI"w32pragma.h" -FI"sehmap.h" -MD -EHsc -wd4141 -wd4291 -wd424...
set cxxflags=-nologo  -Zc:__cplusplus -std:c++17 -GR -FIw32pragma.h -FIsehmap.h -MD -EHsc -wd4141 -wd4291 -wd4244 -w...


PS C:\URANIE\43597>

And the compilation succeeded:

PS C:\URANIE\43597> root -q
   ------------------------------------------------------------------
  | Welcome to ROOT 6.34.02                        https://root.cern |
  | (c) 1995-2024, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for win64 on Dec 15 2024, 07:44:28                         |
  | From tags/v6-34-02@v6-34-02                                      |
  | With MSVC 19.39.33521.0                                          |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'  |
   ------------------------------------------------------------------
PS C:\URANIE\43597> Invoke-Expression "cl test.cpp $(root-config --cflags --libs)"
test.cpp
PS C:\URANIE\43597> .\test.exe
evaluation: 1
PS C:\URANIE\43597>

Thank you very much!

1 Like

Cool, thanks for the feedback!