I am trying to compile the simple example in Visual Studio 2022. Windows 10, Root just installed yesterday: 6.26/06. I created a console project in Visual Studio and then added the include path to the project include settings and the library path to the project library settings. It compiles correctly but gives the 2 linker errors:
||result type of conditional expression is ambiguous: types ‘TString’ and ‘const char ’ can be converted to multiple common types
||‘std::iterator<std::bidirectional_iterator_tag,TObject *,ptrdiff_t,const TObject **,const TObject *&>’: warning STL4015: The std::iterator class template (used as a base class to provide typedefs) is deprecated in C++17. (The header is NOT deprecated.) The C++ Standard has never required user-defined iterators to derive from std::iterator. To fix this warning, stop deriving from std::iterator and start providing publicly accessible typedefs named iterator_category, value_type, difference_type, pointer, and reference. Note that value_type is required to be non-const, even for constant iterators. You can define _SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to acknowledge that you have received this warning.
What did I miss in setting this up?
Welcome to the ROOT forum.
I think @bellenot can help you when he’ll be back.
This has been resolved in the main branch and the v6.26 patch branch (i.e. the upcoming v6.28/00 and v6.26/08)
So, this fix is not yet available? I don’t see it anywhere.
It is currently available only if you build from source.
I am still getting the same C2445 error in Visual Studio with release 6.26/10. The C4996 error no longer occurs when trying to compile your basic example.
Can you give more details about how you build your example, like which exact version of Visual Studio, and with which compiler flags?
The complete error message is:
Severity Code Description Project File Line Suppression State
Error C2445 result type of conditional expression is ambiguous: types ‘TString’ and ‘const char ’ can be converted to multiple common types roottestplot C:\root_v6.26.10\include\TF1.h 463
The compile switches seem to be /RTC1 /Gd /permissive- /EHsc /Gm- /fp:precise /ZcforScope
/Od /Zc:inline /MDd /sdl /GS /JMC /nologo /WX- /Zc:wchar_t /FC /W3
Hope this is sufficient. Thanks
OK, so I suppose you build from inside Visual Studio, right? Can you try to compile on the Visual Studio command prompt corresponding to your version of Visual Studio (what I was asking for) and for the architecture you’re building with this command:
cl -nologo -MD -GR -EHsc -Zc:__cplusplus -std:c++17 [your source files] -I %ROOTSYS%\include /link -LIBPATH:%ROOTSYS%\lib libCore.lib
(and add the libraries you need for your project)
Visual Studio 2022 17.4.3, v 143
OK, so open a
x86 Native Tools Command Prompt for VS 2022 for 32 bit build, or a
x64 Native Tools Command Prompt for VS 2022 for 64 build, and after calling
thisroot.bat (in the bin directory of where you installed ROOT), type the command I posted previously
Well, it compiles, but I am getting link errors to TF1 and TCanvas. This is real progress, though.
libHist.lib, and most probably
That did it. Thank you very much.
You’re welcome. And BTW, you should use CMake for your projects, that would be much easier