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

**URL:** <https://root-forum.cern.ch/t/i-can-compile-my-c-source-code-with-cl-exe-but-when-i-run-the-program-nothing-outputs/55282>\
**Category:** Newbie\
**Tags:** root\
**Created:** [June 13, 2023, 2:34pm UTC](https://root-forum.cern.ch/t/i-can-compile-my-c-source-code-with-cl-exe-but-when-i-run-the-program-nothing-outputs/55282 "2023-06-13T14:34:38Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![mspeck](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mspeck](https://root-forum.cern.ch/u/mspeck)\
**Post date:** [June 13, 2023, 2:34pm UTC](https://root-forum.cern.ch/t/i-can-compile-my-c-source-code-with-cl-exe-but-when-i-run-the-program-nothing-outputs/55282/1 "2023-06-13T14:34:38Z")

</div>

_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

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [June 13, 2023, 2:37pm UTC](https://root-forum.cern.ch/t/i-can-compile-my-c-source-code-with-cl-exe-but-when-i-run-the-program-nothing-outputs/55282/2 "2023-06-13T14:37:02Z")

</div>

Welcome to the ROOT Forum!  
What you show here:

```auto
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…

---

<div class="post-metadata">

**Author:** ![mspeck](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mspeck](https://root-forum.cern.ch/u/mspeck)\
**Post date:** [June 13, 2023, 2:41pm UTC](https://root-forum.cern.ch/t/i-can-compile-my-c-source-code-with-cl-exe-but-when-i-run-the-program-nothing-outputs/55282/3 "2023-06-13T14:41:16Z")

</div>

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

Here is my code:

```auto
#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

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [June 13, 2023, 2:50pm UTC](https://root-forum.cern.ch/t/i-can-compile-my-c-source-code-with-cl-exe-but-when-i-run-the-program-nothing-outputs/55282/4 "2023-06-13T14:50:17Z")

</div>

I don’t see any problem:

```auto
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 . . .

```

---

<div class="post-metadata">

**Author:** ![mspeck](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mspeck](https://root-forum.cern.ch/u/mspeck)\
**Post date:** [June 13, 2023, 2:59pm UTC](https://root-forum.cern.ch/t/i-can-compile-my-c-source-code-with-cl-exe-but-when-i-run-the-program-nothing-outputs/55282/5 "2023-06-13T14:59:41Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [June 13, 2023, 3:02pm UTC](https://root-forum.cern.ch/t/i-can-compile-my-c-source-code-with-cl-exe-but-when-i-run-the-program-nothing-outputs/55282/6 "2023-06-13T15:02:45Z")

</div>

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)?

---

<div class="post-metadata">

**Author:** ![mspeck](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mspeck](https://root-forum.cern.ch/u/mspeck)\
**Post date:** [June 13, 2023, 3:07pm UTC](https://root-forum.cern.ch/t/i-can-compile-my-c-source-code-with-cl-exe-but-when-i-run-the-program-nothing-outputs/55282/7 "2023-06-13T15:07:56Z")

</div>

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\>

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [June 13, 2023, 3:11pm UTC](https://root-forum.cern.ch/t/i-can-compile-my-c-source-code-with-cl-exe-but-when-i-run-the-program-nothing-outputs/55282/8 "2023-06-13T15:11:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mspeck](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mspeck](https://root-forum.cern.ch/u/mspeck)\
**Post date:** [June 13, 2023, 3:24pm UTC](https://root-forum.cern.ch/t/i-can-compile-my-c-source-code-with-cl-exe-but-when-i-run-the-program-nothing-outputs/55282/9 "2023-06-13T15:24:20Z")

</div>

Thank you very much

---

<div class="post-metadata">

**Author:** ![mspeck](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mspeck](https://root-forum.cern.ch/u/mspeck)\
**Post date:** [June 13, 2023, 6:57pm UTC](https://root-forum.cern.ch/t/i-can-compile-my-c-source-code-with-cl-exe-but-when-i-run-the-program-nothing-outputs/55282/10 "2023-06-13T18:57:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [June 14, 2023, 7:18am UTC](https://root-forum.cern.ch/t/i-can-compile-my-c-source-code-with-cl-exe-but-when-i-run-the-program-nothing-outputs/55282/11 "2023-06-14T07:18:46Z")

</div>

When do you get this error? with which DLL?
