Canvas out of a Code::Blocks

Hi,

I am quite new to using Root.

I installed root on an ubuntu 12.10 system. I startet a project in Code::Blocks and and added the libraries and compilerinfos on the “build options”. My project just compiles fine, but i do not get any graphical output.

[code]#include

using namespace std;
#include “TF1.h”
#include “TCanvas.h”
#include "TH1.h"
int main()
{
TF1* func = new TF1(“func”,“x”,0.,10.);
TH1* h1 = new TH1F(“h1”,“h1”,100,0,10);
for (int i = 0; i < 10000; i++){
h1->Fill(func->GetRandom());
}
h1->Draw();
return 0;
}[/code]

This is the output i get:

[code]
Info in TCanvas::MakeDefCanvas: created default TCanvas with name c1

Process returned 0 (0x0) execution time : 0.154 s
Press ENTER to continue.[/code]

So is it possible to show the canvas upon launching the project out of code::blocks or do i need to execute this file inside root everytime?

Try: [code]#include “TApplication.h”
#include “TF1.h”
#include “TH1.h”

int main()
{
TApplication *app = new TApplication(“app”, 0, 0);

TF1* func = new TF1(“func”,“x”,0.,10.);
TH1F* h1 = new TH1F(“h1”,“h1”,100,0,10);
for (int i = 0; i < 10000; i++){
h1->Fill(func->GetRandom());
}
h1->Draw();

app->Run(kTRUE); // “exit” = canvas’es “main menu” -> “File” -> "Quit ROOT"
return 0;
}[/code]

Thank you Wile E. Coyote.

Works perfect.