# On Visual Studio 2022 Root running problem

**URL:** <https://root-forum.cern.ch/t/on-visual-studio-2022-root-running-problem/53636>\
**Category:** Newbie\
**Tags:** root\
**Created:** [February 15, 2023, 4:49am UTC](https://root-forum.cern.ch/t/on-visual-studio-2022-root-running-problem/53636 "2023-02-15T04:49:01Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [February 15, 2023, 7:43am UTC](https://root-forum.cern.ch/t/on-visual-studio-2022-root-running-problem/53636/2 "2023-02-15T07:43:03Z")

</div>

Welcome to the ROOT Forum!

Make sure you build with the same flags than the ones used to build ROOT. Since you only have one source file, I would suggest to build in the `x64 Native Tools Command Prompt for VS 2022`. Something like this:

```auto
cl -nologo -MD -GR -EHsc -Zc:__cplusplus -std:c++17 RooPlot.cxx -I %ROOTSYS%\include /link -LIBPATH:%ROOTSYS%\lib libCore.lib libGui.lib libHist.lib libGpad.lib

```

And if you want your program (your TCanvas) to stay open, you have to add an instance of `TApplication`. Something like:

```auto
#include <TApplication.h>
#include <TF1.h>

int main(int argc, char** argv)
{
   TApplication app("app", &argc, argv);
   TF1* f1 = new TF1("f1", "sin(x)/x" , 0, 10);
   f1->Draw();
   app.Run();
   return 0;
}

```

---

_[View the full topic](https://root-forum.cern.ch/t/on-visual-studio-2022-root-running-problem/53636)._
