Why Canvas don't create window

Dear Experts

I want to see some plot after running a program, so I wrote

TCanvas* Canvas = new TCanvas();
TH2D* histo = new TH2D(xxx,xxx,xxx,xxx);
// some code

But after the program finished the window didn’t come out. How can I make it create a window?

Please read tips for efficient and successful posting and posting code

ROOT Version: 6.26.02
Platform: MacOS
Compiler: gcc

I see at least one mistake: you define hits and you draw histo.

Sorry this is just for example… actually is a typo when I ask this question. I can save the canvas in the root file and see it from root file, but I just can’t see it after the program finished.

file crisps.C

void crisps() {
   auto Canvas = new TCanvas();
   auto hist = new TH2D("","",40,-1,1,40,-1,1);


root [0] .x crisps.C

Yes, the problem is, when I use root and type

.x crisps.cxx

I can get the window, but when I compile it by gcc and run it, the window doesn’t come out…

Have you made a standalone program as described in the Manual?

Yes, I made one you wrote above and compiled it, and the window doesn’t come out.

You should do what is described in the interactive part of the page I sent you.

It works! Never use Application before but the window only doesn’t come out after I changed to new MacBook…Thank you very much!

That’s not new. It has always been that way.