Root v6.16 VS2017 Common Language Runtime Support

Will rootv6.16 compile with Visual studio 2017 Common Language Runtime Support (CLR)?
I get errors like:

fatal error C1189: #error: mutex is not supported when compiling with /clr or /clr:pure.

This was not the case with root5.34


_ROOT Version: 6.16
_Platform: Windows
_Compiler VS2017


I never tried to build ROOT with CLR enabled… Did you check this MSDN page?

The code was and is still running with /clr, root v5 and VS2013.
The problem comes when switching to /clr, root v6 and VS2017.
Do you know by chance whether root v6 code uses #include<mutex>? This could at least explain the error message with \clr.

I’ll grep for it and let you know…

I didn’t find any, but it might be an implicit #include

BTW, how did you try to compile with /clr? Did you simply modify the CMake flags?

I compile in VS2017 directly by linking the root binaries. I set the CLR by
Project–> Properties–>General–> Common Language Runtime Support (/clr)

I setup a new VS project with a root “Hello World example”.
It seems that the compilation error message comes via #include"Tfile.h"

/ rootTest.cpp : Defines the entry point for the console application.
//
#include
#include “stdafx.h”
#include “windows4root.h”
#include “TLatex.h”
#include “TCanvas.h”
#include “TPaveTexT.h”
#include “TString.h”
//#include “TFile.h”
#include “TH1F.h”
#include “TH2F.h”
#include
#include “TApplication.h”
#include “TCanvas.h”
#include “TLine.h”
#include “TPaveLabel.h”
int main(int argc, char **argv)
{
TApplication theApp(“App”, &argc, argv);
TCanvas *c = new TCanvas(“c”, “The Hello Canvas”, 400, 400);

TPaveLabel *hello = new TPaveLabel(0.2, 0.4, 0.8, 0.6, “Hello World”);
hello->Draw();
TPaveLabel *quit = new TPaveLabel(0.2, 0.2, 0.8, 0.3, “Close via menu File/Quit”);
quit->Draw();
c->Update();

// Enter event loop, one can now interact with the objects in
// the canvas. Select “Exit ROOT” from Canvas “File” menu to exit
// the event loop and execute the next statements.
theApp.Run(kTRUE);

TLine *l = new TLine(0.1, 0.2, 0.5, 0.9);
l->Draw();
quit->SetLabel(“Select File/Quit again to exit app”);
c->Update();

// Here we don’t return from the eventloop. “Exit ROOT” will quit the app.
theApp.Run();

return 0;
}

if I include TFile I get the error message:

1>------ Build started: Project: rootTest, Configuration: Debug Win32 ------
1>rootTest.cpp
1>c:\root_v6.16.00debug\include\root\libcpp_string_view.h(193): warning C4068: unknown pragma
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\mutex(8): fatal error C1189: #error: is not supported when compiling with /clr or /clr:pure.
1>Done building project “rootTest.vcxproj” – FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

without TFile it compiles.

I just looked into my TFile.h . I found the include line.

/ @(#)root/io:Id
// Author: Rene Brun 28/11/94

/*************************************************************************

  • Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
  • All rights reserved. *
  •                                                                   *
    
  • For the licensing terms see $ROOTSYS/LICENSE. *
  • For the list of contributors see $ROOTSYS/README/CREDITS. *
    *************************************************************************/

#ifndef ROOT_TFile
#define ROOT_TFile

//////////////////////////////////////////////////////////////////////////
// //
// TFile //
// //
// ROOT file. //
// //
//////////////////////////////////////////////////////////////////////////

#include

#include “Compression.h”
#include “TDirectoryFile.h”
#include “TMap.h”
#include “TUrl.h”
#include “ROOT/RConcurrentHashColl.hxx”

#ifdef R__USE_IMT
#include “ROOT/TRWSpinLock.hxx”
#include <mutex>
#endif

This explains at least the error-message.
But I am not sure how to avoid. On the web I found advices like:

or

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