Error when compiling FB / GTK tuto sample

Linux specific questions.
Post Reply
Wawa
Posts: 3
Joined: Feb 09, 2012 10:22

Error when compiling FB / GTK tuto sample

Post by Wawa »

Hello,

I try to compile the following code under linux (Kubuntu 12.10) :

Code: Select all

ZetCode FreeBASIC GTK tutorial
'
' This program centers a window on 
' the screen
'
' author Jan Bodnar
' last modified July 2010
' website www.zetcode.com

#include once "gtk/gtk.bi"

#define NULL 0

Dim As GtkWidget Ptr win

gtk_init(NULL, NULL)

win = gtk_window_new(GTK_WINDOW_TOPLEVEL)
gtk_window_set_title(GTK_WINDOW(win), "Center")
gtk_widget_set_size_request(win, 250, 150)
gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_CENTER)

g_signal_connect(G_OBJECT(win), "destroy", _
    G_CALLBACK (@gtk_main_quit), NULL)

gtk_widget_show(win)
gtk_main()

END 0
This come from a FreeBasic - GTK tutorial : "http://zetcode.com/gui/fbgtk/".

When I compile I receive the following errors :
ld : ne peut trouver -lgtk-x11-2.0
ld : ne peut trouver -lgdk-x11-2.0

Any ideas on what I should do to get this code working ?

Many thanks for the help.

Philippe
Wawa
Posts: 3
Joined: Feb 09, 2012 10:22

Re: Error when compiling FB / GTK tuto sample

Post by Wawa »

Hello,

Me again.

I have try to compile the gtk+ example provided with fb 0.24.0 an I got exactly the two same errors...

Any idea on what I should do to avoid the problem ?

Thanks for the help.

Philippe
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: Error when compiling FB / GTK tuto sample

Post by TJF »

Hello Wawa, welcome at the forum!

I cant read French but I assume that the linker ld cannot find the two libraries. One reason may be that in Ubuntu 12.10 only GTK+-3.0 is installed by default and you have to install GTK-2.0 manually:
  • sudo apt-get install libgtk2.0-dev
But you also can switch to the newer version by prepending
  • #DEFINE __USE_GTK3__
befor the #INCLUDE ONCE "gtk/gtk.bi" statement in your code. (This DEFINE is allready prepared in the examples shipped with fbc-0.24.) Then you need to install the development package for GTK+3 by executing
  • sudo apt-get install libgtk-3-dev
Post Reply