# Canvas not created in compiled code

**URL:** <https://root-forum.cern.ch/t/canvas-not-created-in-compiled-code/63047>\
**Category:** ROOT\
**Created:** [February 28, 2025, 12:31am UTC](https://root-forum.cern.ch/t/canvas-not-created-in-compiled-code/63047 "2025-02-28T00:31:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dhymers](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dhymers/32/22059_2.png) [@dhymers](https://root-forum.cern.ch/u/dhymers)\
**Post date:** [February 28, 2025, 12:31am UTC](https://root-forum.cern.ch/t/canvas-not-created-in-compiled-code/63047/1 "2025-02-28T00:31:52Z")

</div>

I am unable to open graphical windows in a compiled application using ROOT libraries. Here is example code:

```auto
//test.cc
#include "TCanvas.h"
#include "TH1D.h"

#include <iostream>

void test(void){
    TCanvas* c = new TCanvas("c", "c");
    
    TH1D* hist = new TH1D("hist", "hist", 10, -5.0, 5.0);
    
    hist->Fill(-3);
    hist->Fill(-1);
    hist->Fill(1);
    hist->Fill(3);
    
    hist->Draw("HIST");
}

int main(void){
    test();
    
    // Just here to wait and see if window is being created
    std::string s;
    std::cin >> s;
    
    return 0;
}

```

This code can be run directly via `root test.cc`, and produces a simple histogram in its own window. However, when compiled, via `g++ test.cc `root-config --cflags --glibs` -o test`, and running `./test`, no window is created.

Could this be some issue with my build of Root? I did build this myself from source, but didn’t do anything unusual.

ROOT Version: 6.28/10  
Platform: Linux  
Compiler: g++ 11.4.0

---

<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 28, 2025, 7:24am UTC](https://root-forum.cern.ch/t/canvas-not-created-in-compiled-code/63047/2 "2025-02-28T07:24:18Z")

</div>

Welcome to the ROOT Forum!  
Did you try to search the forum for the same issue? See for example [TCanvas doesn't show up - #4 by dastudillo](https://root-forum.cern.ch/t/tcanvas-doesnt-show-up/62694/4)

---

<div class="post-metadata">

**Author:** ![dhymers](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dhymers/32/22059_2.png) [@dhymers](https://root-forum.cern.ch/u/dhymers)\
**Post date:** [February 28, 2025, 4:12pm UTC](https://root-forum.cern.ch/t/canvas-not-created-in-compiled-code/63047/3 "2025-02-28T16:12:17Z")

</div>

I did a search, but clearly wasn’t using the right keywords. Thanks for the help!

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [March 14, 2025, 4:12pm UTC](https://root-forum.cern.ch/t/canvas-not-created-in-compiled-code/63047/4 "2025-03-14T16:12:19Z")

</div>

Closed on March 14, 2025, 4:12pm UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
