PDA

View Full Version : How to install GTK with C development??


sands
February 22nd, 2006, 01:38 PM
Hi,Im a newbie to linux programming. I want to prgram in C with GTK.
Can anyone guide me how to install the packages required..I installed a anjuta ide .
But some errors are comming wile compiling and building.

while compiling in terminal

gcc 1.c -o base 'gtk-config -cflags -libs'

gcc: gtk-config -cflags -libs: No such file or directory
1.c:2:21: error: gtk/gtk.h: No such file or directory
1.c: In function ‘main’:
1.c:6: error: ‘GtkWidget’ undeclared (first use in this function)
1.c:6: error: (Each undeclared identifier is reported only once
1.c:6: error: for each function it appears in.)
1.c:6: error: ‘window’ undeclared (first use in this function)
1.c:8: error: ‘GTK_WINDOW_TOPLEVEL’ undeclared (first use in this function)


Help me!!

sapo
February 22nd, 2006, 01:46 PM
sudo apt-get install libgtk2.0-dev

this should solve your problem :)

sands
February 22nd, 2006, 02:03 PM
again the same error!!!

sandesh@sandesh:~/gtk$ gcc 1.c -o base 'gtk-config -cflags -libs'
gcc: gtk-config -cflags -libs: No such file or directory
1.c:2:21: error: gtk/gtk.h: No such file or directory
1.c: In function ‘main’:
1.c:6: error: ‘GtkWidget’ undeclared (first use in this function)
1.c:6: error: (Each undeclared identifier is reported only once
1.c:6: error: for each function it appears in.)
1.c:6: error: ‘window’ undeclared (first use in this function)
1.c:8: error: ‘GTK_WINDOW_TOPLEVEL’ undeclared (first use in this function)

fct
February 22nd, 2006, 04:16 PM
From the way you are compiling (gtk-config is obsolete) I guess you're using an outdated gtk1.2 manual. Check the current 2.0 tutorial instead:

http://gtk.org/tutorial/

sands
February 22nd, 2006, 10:11 PM
I downloaded the latest manual (GTK+ 2.0 Tutoria)l frm www.gtk.org .
the syntax tat is given to compile, I copy pasted it in the terminal.
I guess there is some prob with my installation.

andrew4558
March 16th, 2008, 06:39 PM
To compile a gtk program, do this in console ( i.e: your program is called base.c):
$ gcc -Wall -g base.c -o base `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0`

Note: You must have the tick key ( `) before and after the pkg-config -cflags and libs.
The tick key is found on the left below the Esc key on your keyboard. To check if pkg-config
is installed in your system, type: pkg-config --cflags --libs glib-2.0

bruce89
March 16th, 2008, 08:47 PM
To compile a gtk program, do this in console ( i.e: your program is called base.c):
$ gcc -Wall -g base.c -o base `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0`


More short:

gcc -g -Wall `pkg-config --cflags --libs gtk+-2.0` -o base base.c

WW
March 16th, 2008, 11:03 PM
andrew4558 called the delimiting character a "tick". I've also heard it called a "single back quote" or a "back tick".

I've been told that this character is not standard on some keyboards in Europe (German?). An alternative method to achieve the effect is to use $(comands...) instead of `commands...`, i.e.

gcc -g -Wall $(pkg-config --cflags --libs gtk+-2.0) -o base base.c

ementos
January 15th, 2010, 02:43 PM
I wrote that and I gon new error:
$ gcc -g -Wall $(pkg-config --cflags --libs gtk+-2.0) -o base gtkpp.cpp
/tmp/ccyFeV8e.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status

What's that?

Zugzwang
January 15th, 2010, 03:09 PM
What's that?

This error occurs when you try to compile a C++ program with "gcc" instead of "g++". BTW: A quick google search would have told you that.

ementos
January 15th, 2010, 03:13 PM
Thanks a lot =)

ementos
November 2nd, 2010, 01:24 PM
I have only one question... cause some of GTK examples programms is able to compile, but at least one because I was writing some exercises to set label text, but any worked... even when I coppied last example from this site (Increase - Decrease): http://zetcode.com/tutorials/gtktutorial/firstprograms/
and it wasn't able to compile... Is something wrong with my library?
Greet
Józek