Includes error in VS2019 (RWrap_libcpp_string_view.h)

Did not work :frowning:

Before building what?

Before building the root_6.18.04 from source on Windows for VS19 using cmake-gui. All the softwares are up-to-date. I downloaded and installed them today.

So I don’t understand why you installed the binaries before building from source. Or did I miss something?

Previously, I was fine with the binaries as I was using the interpreter. Now, recently I have moved to compiler for better performance. I have WSL with Ubuntu installed where I use the g++ command. More specifically,

g++ source1.cpp source2.cpp source3.cpp `root-config --glibs --cflags`

where source1.cpp has the main() function and the rest contain the definition of the header files. I want to do have a similar experience natively on Windows. Till now, I have only been able to run root command in cmd but I am still failing to do what I want, i.e. compile using native compiler. I have been using Compile ROOT v6.16 with Visual studio 2019 successfully! (Good news for me!) and Root on windows (Visual studio 2010) as instructions.

Then I would suggest to build from source and disable Python, and then try to compile your code (obviously the g++ syntax will not work)

Should I disable python in the cmake-gui? Without python installed I get CMake Error:

...
Looking for python
CMake Error at C:/Program Files/CMake/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
  Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE)
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
  C:/Program Files/CMake/share/cmake-3.16/Modules/FindPythonInterp.cmake:169 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  cmake/modules/SearchInstalledSoftware.cmake:9 (_find_package)
  cmake/modules/SearchInstalledSoftware.cmake:438 (find_package)
  CMakeLists.txt:159 (include)


Configuring incomplete, errors occurred!
See also "C:/ROOT/root-6.18.04/CMakeFiles/CMakeOutput.log".
See also "C:/ROOT/root-6.18.04/CMakeFiles/CMakeError.log".

Oh yes, sorry, you’re right, Python is required (it was not in the past)…

To be precise, you can disable Python, but you need to set the correct value for PYTHON_EXECUTABLE

OK, so I am building ROOT 6.18/04 on Windows 10 v1909 (64-bit OS, x64 processor) using Microsoft Visual Studio Community 2019 v16.4.3 and cmake 3.16.3 (installed outside VS) with python-3.8.1 installed (Windows x86 executable installer). I am disable python flag and enabling minuit2 flag as I need it. Here are my configuration option for cmake-gui:
image
and here are the configuration output:

Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.18363.
ROOT default compression algorithm: zlib
ROOT Platform: win32
ROOT Architecture: win32
Build Type: RelWithDebInfo
Compiler Flags: -nologo -IC:/ROOT/root_v6.18.04.source/root-6.18.04/build/win -FIw32pragma.h -FIsehmap.h -Zc:__cplusplus -MD -GR -EHsc- -W3 -wd4141 -wd4291 -wd4244 -wd4049 -D_WIN32 -D_XKEYCHECK_H -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -DNOMINMAX -D_CRT_SECURE_NO_WARNINGS  
Building freetype version 2.6.1 included in ROOT itself
Building LZMA version 5.2.4 included in ROOT itself
Could NOT find GIF (missing: GIF_LIBRARY GIF_INCLUDE_DIR) 
Could NOT find TIFF (missing: TIFF_LIBRARY TIFF_INCLUDE_DIR) 
Could NOT find PNG (missing: PNG_LIBRARY PNG_PNG_INCLUDE_DIR) 
Could NOT find JPEG (missing: JPEG_LIBRARY JPEG_INCLUDE_DIR) 
Looking for python
Looking for OpenGL
Enabled support for:  asimage astiff builtin_afterimage builtin_clang builtin_freetype builtin_ftgl builtin_gl2ps builtin_glew builtin_llvm builtin_lz4 builtin_lzma builtin_pcre builtin_xxhash builtin_zlib clad cling exceptions explicitlink gdml http minuit2 opengl pch shared thread
Could NOT find Backtrace (missing: Backtrace_LIBRARY Backtrace_INCLUDE_DIR) 
Native target architecture is X86
Threads disabled.
Doxygen disabled.
Go bindings disabled.
LLVM host triple: i686-pc-win32
LLVM default target triple: i686-pc-win32
Using MinSizeRel VC++ CRT: MD
Constructing LLVMBuild project information
LLVMHello ignored -- Loadable modules not supported on this platform.
Targeting X86
Clang version: 5.0.0
PrintFunctionNames ignored -- Loadable modules not supported on this platform.
AnnotateFunctions ignored -- Loadable modules not supported on this platform.
BugpointPasses ignored -- Loadable modules not supported on this platform.
Cling version (from VERSION file): ROOT_0.6~dev
Recording the git revision now
Performing Test found_stdstringview
Performing Test found_stdstringview - Failed
Performing Test found_stdexpstringview
Performing Test found_stdexpstringview - Failed
Performing Test found_stdapply
Performing Test found_stdapply - Failed
Performing Test found_stdinvoke
Performing Test found_stdinvoke - Success
Performing Test found_stdindexsequence
Performing Test found_stdindexsequence - Success
Configuring done

Proceeding to build.
PS: when I enable minuit2 flag, 2 other flags pop up: minuit2-mpi and minuit2-omp. Do I need to enable them for basic functionality of the Minuit2Minimizer?

I don’t see any entry with this name in cmake-gui

No, minuit2 is sufficient

OK, you’re building an old version. this option is visible in the master

Build complete.

========== Build: 383 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

At the end of the build, this showed up:
image
Still the same error:

1>------ Build started: Project: TestProject, Configuration: Debug Win32 ------
1>TestProject.cpp
1>C:\ROOT\root-6.18.04\include\ROOT\RWrap_libcpp_string_view.h(428,34): error C2039: '__find_end': is not a member of 'std'
1>C:\ROOT\root-6.18.04\include\ROOT\RWrap_libcpp_string_view.h(125): message : see declaration of 'std'
1>C:\ROOT\root-6.18.04\include\ROOT\libcpp_string_view.h(193,9): warning C4068: unknown pragma
1>Done building project "TestProject.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Am I missing any compiler flags?

Maybe. Which flags are you using?

None. I have just included headers, library dir and libCore.lib;libGpad.lib;libGui.lib in linkers

You have to use the same flags than ROOT… can you try the following on the x86 VS 2019 command prompt:

cl /nologo /TP /Z7 /MD /GR /EHsc /I %ROOTSYS%\include TestProject.cpp /link /LIBPATH:%ROOTSYS%\lib libCore.lib libMathCore.lib

(you might need more libraries, depending on what’s inside your TestProject.cpp)

OK so it did compile! But what to do next? Here’s my code:

#include <iostream>

#include <TROOT.h>
#include <TCanvas.h>


int main()
{
    std::cout << "Hello World!\n";
}

Use the same flags that the ones in the line above (either in your IDE, or in the command prompt).

I am running the TestProject.exe and it should output Hello world! but it doesn’t.