It works for me. And since it doesn’t use any ROOT component, ROOT is not even needed for this example…
C:\Users\bellenot\rootdev>cl /nologo /TP /Z7 /MD /GR /EHsc /I %ROOTSYS%\include TestProject.cpp /link /LIBPATH:%ROOTSYS%\lib libCore.lib libMathCore.lib
TestProject.cpp
C:\Users\bellenot\rootdev>TestProject
Hello World!
C:\Users\bellenot\rootdev>
Here’s my output:
G:\TestROOTVC\TestProject\TestProject>cl /nologo /TP /Z7 /MD /GR /EHsc /I C:\ROOT\root-6.18.04\include TestProject.cpp /link /LIBPATH:C:\ROOT\root-6.18.04\lib libCore.lib libMathCore.lib TestProject.cpp
G:\TestROOTVC\TestProject\TestProject>TestProject.exe
G:\TestROOTVC\TestProject\TestProject>
Try this code:
#include <iostream>
//#include <TROOT.h>
//#include <TCanvas.h>
int main()
{
std::cout << "Hello World!\n";
}
And compile with:
cl /nologo /TP /Z7 /MD /GR /EHsc TestProject.cpp /link
So there is no ROOT involved
It does and shows output.
Then use your original code, rebuild with ROOT and to debug it like this:
G:\TestROOTVC\TestProject\TestProject>devenv /debugexe TestProject.exe
This will open the debugger, then you can step in to see what’s happening
Here’s the output:
'TestProject.exe' (Win32): Loaded 'G:\TestROOTVC\TestProject\TestProject\TestProject.exe'. Symbols loaded.
'TestProject.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'.
'TestProject.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'.
'TestProject.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'.
'TestProject.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ucrtbase.dll'.
'TestProject.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp140.dll'.
'TestProject.exe' (Win32): Loaded 'C:\Windows\SysWOW64\vcruntime140.dll'.
The thread 0x4004 has exited with code -1073741515 (0xc0000135).
The thread 0x49d4 has exited with code -1073741515 (0xc0000135).
The program '[13336] testproject.exe' has exited with code -1073741515 (0xc0000135) 'A dependent dll was not found'.
Here’s the error dialog box:

You must have ROOTSYS properly set and %ROOTSYS%\bin in your PATH. You can simply call C:\ROOT\root-6.18.04\bin\thisroot.bat in the command prompt, before running your application (this might already fix your problem)
Sorry, this is so basic that I forgot to mention it…
This fixed it! Thanks a lot!