On Visual Studio 2022 Root running problem

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:

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:

#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;
}