Criando um HelloWorld em FLTK2

Embora eu seja um novato em materia de bibliotecas graficas, ha’ muito tempo eu tenho uma grande admiracao pela FLTK. Ela e’ uma biblioteca pequena, flexivel e muito rapida.

Entao resolvi botar a mao na massa e comecar a brincar um pouco com ela. Para que mais pessoas possam fazer o mesmo resolvi postar um passo-a-passo aqui.

Primero baixe o codigo fonte da FLTK2 mais recente:
http://www.fltk.org/software.php?VERSION=1.3.x-r6176&FILE=fltk/snapshots/fltk-2.0.x-r6176.tar.bz2

Descompacte como de costume:
tar jxvf fltk-2.0.x-r6176.tar.bz2

Compile da forma usual:
cd fltk-2.0.x-r6176/
./configure
make
make install

Crie um arquivo com o nome hello.cxx com o conteudo:

#include <fltk/Window.h>
#include <fltk/Widget.h>
#include <fltk/run.h>

using namespace fltk;

int main(int argc, char **argv){
        Window *window = new Window(400, 200);
        window->begin();
        Widget *box = new Widget(10,10,360,160,"Hello World!");
        box->box(UP_BOX);
        box->labelfont(HELVETICA_BOLD_ITALIC);
        box->labelsize(36);
        box->labeltype(SHADOW_LABEL);
        window->end();
	window->show(argc,argv);
	return run();
}

Compile:

g++ -I/usr/local/include -c hello.cxx
g++ hello.o -o hello -L/usr/local/lib -lfltk2 -lXext -lXinerama -lXft -lXi -lX11 -lm

Execute:

./hello

Voce devera’ ver a seguinte tela:

Hello World

Hello World

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s