Creating ROOT program with Visual Studio

I want to create a ROOT program with Visual Studio. I add includes and libraries from ROOT (all information I found here ). Then I wrote this code:

#include <TApplication.h>
#include <TF1.h>
int main(int argc, char **argv)
TApplication theApp("App",&amp;argc,argv);
TF1 *f1 = new TF1("f1","sin(x)/x",0,gRandom-&gt;Rndm()*10);
return 0;

And I have: fatal error C1001: An internal error has occurred in the compiler in typetraits. hxx ( line 43)
in this code:

struct CallableTraitsImpl<T, true> {
   using arg_types = typename CallableTraitsImpl<decltype(&T::operator())>::arg_types;
   using arg_types_nodecay = typename CallableTraitsImpl<decltype(&T::operator())>::arg_types_nodecay;
   using ret_type = typename CallableTraitsImpl<decltype(&T::operator())>::ret_type;

Please help me


Which exact version of Visual Studio are you using?

And BTW, it’s much simpler to use the command line, especially for very simple projects. For example, with your source being main.cxx:

cl -nologo -MD -GR -EHsc -I%ROOTSYS%\include -FIw32pragma.h main.cxx /link -LIBPATH:%ROOTSYS%\lib libCore.lib libHist.lib libGraf.lib libGpad.lib

Cheers, Bertrand.

Version of Visual Studio: Visual Studio Community 2017 15.9.3

OK, there is at lease one problem with this version of Visual Studio. The compiler contains a bug, as you can see on this bug report. The last working version is 15.7.6

1 Like

After installing version 15.7.6 apperared error:

C4996 ‘std::copy::_Unchecked_iterators::_Deprecate’: Call to ‘std::copy’ with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ ‘Checked Iterators’ root_c_15_6_7 c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.14.26428\include\xutility 2483

Don’t worry, it’s not an error, it’s a warning…