I can compile my C++ source code with cl.exe but when I run the program nothing outputs

ROOT Version: v_6.24.04
Platform: Windows 10
Compiler: x86 Visual Studio Native Tools


I am having Trouble running my source code as it s not outputting anything:

cl -EHsc -Zc:__cplusplus -std:c++17 rootTest.cpp -I C:\root_v6.26.04\include /link -LIBPATH:C:\root_v6.26.04\lib libCore.lib libGui.lib libHist.lib

Welcome to the ROOT Forum!
What you show here:

cl -EHsc -Zc:__cplusplus -std:c++17 rootTest.cpp -I C:\root_v6.26.04\include /link -LIBPATH:C:\root_v6.26.04\lib libCore.lib libGui.lib libHist.lib

is not running anything, it’s just using cl.exe to compile the code…

Apologies, should have included that I ran ‘rootTest.exe’

Here is my code:

#include <iostream>
#include <time.h>
#include <windows.h>

#include "TCanvas.h"
#include "TH1F.h"


int main() {
    std::cout << "Hello World\n";
	printf("Hello World\n");
	system("pause");
	// TCanvas canvas("canvas", "My Canvas", 800, 600);
	// TH1F hist("hist", "My Histogram", 100, 0, 1);
	// hist.FillRandom("gaus", 10000);
	// hist.Draw();
	// canvas.SaveAs("output.png");

	return 0;
}

and when I run rootTest.exe, nothing outputs

I don’t see any problem:

C:\Users\bellenot\rootdev\forum>cl -EHsc -Zc:__cplusplus -std:c++17 roottest.cxx -I %ROOTSYS%\include /link -LIBPATH:%ROOTSYS%\lib libCore.lib libGui.lib libHist.lib
Microsoft (R) C/C++ Optimizing Compiler Version 19.29.30148 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

roottest.cxx
Microsoft (R) Incremental Linker Version 14.29.30148.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:roottest.exe
-LIBPATH:C:\Users\bellenot\build\x86\release\lib
libCore.lib
libGui.lib
libHist.lib
roottest.obj

C:\Users\bellenot\rootdev\forum>roottest
Hello World
Hello World
Press any key to continue . . .

So I downloaded the root.exe file for Visual Studio 2019 from the website, after downloading and running the installer, is there anything else I need to do?

Just calling C:\root_v6.26.04\bin\thisroot.bat before compiling and most importantly before running your application. Do you have any error when building your application? Can you copy and paste exactly what you’re doing (like I did)?

Here is what I do:

C:\Users\Michael\OneDrive\Desktop\RootTest>C:\root_v6.26.04\bin\thisroot.bat

C:\Users\Michael\OneDrive \Desktop\RootTest>cl -EHsc -Zc:__cplusplus -std:c++17 rootTest.cxx -I C:\root_v6.26.04\include /link -LIBPATH:C:\root_v6.26.04\lib libCore.lib libGui.lib libHist.lib
Microsoft (R) C/C++ Optimizing Compiler Version 19.29.30145 for x86
Copyright (C) Microsoft Corporation. All rights reserved.

rootTest.cxx
Microsoft (R) Incremental Linker Version 14.29.30145.0
Copyright (C) Microsoft Corporation. All rights reserved.

/out:rootTest.exe
-LIBPATH:C:\root_v6.26.04\lib
libCore.lib
libGui.lib
libHist.lib
rootTest.obj

C:\Users\Michael\OneDrive\Desktop\RootTest>C:\root_v6.26.04\bin\thisroot.bat

C:\Users\Michael\OneDrive\Desktop\RootTest>rootTest

C:\Users\Michael\OneDrive\Desktop\RootTest>

Well, then I don’t know. I’ll try to guess what could be wrong…

Thank you very much

Am I suppposed to anything with DLLs? I am getting a 0xc000142 error

When do you get this error? with which DLL?