
July 21st, 2012, 02:55 PM
|
|
Registered User
|
|
Join Date: Jul 2012
Posts: 1
Time spent in forums: 19 m 53 sec
Reputation Power: 0
|
|
|
Cant compile GTK hello world program in cygwin
I have been trying to compile a simple gtk, C based program in cygwin and i've been googling all day but nothing works. I have downloaded all the appropriate packages but it seems that cygwin can see the gtk libraries. I am using windows 7 64 bit.
when I compile
#include <gtk/gtk.h>
/*call back function:
*/
static void hello( GtkWidget *widget,
gpointer data)
{
g_print("Hello world\n");
}
static gboolean delete_event(GtkWidget *widget,
Gdk *event,
gpointer data)
{
g_print("delete event occured\n");
/*change true to false and the main window will be
destroyed with a delete-event*/
return true;
}
/*Another call back function*/
static void destroy(GtkWidget *widget,
gpointer data)
{
gtk_main_quit();
}
int main(int argc, char *argv[])
{
/*GtkWidget is the storage type for widgets.
initialise window and button?*/
GtkWidget *window;
GtkWidget *button;
/*This is called in all GTK applications. Arguments
are parsed from the command line and are returned
to the application. */
gtk_init (&argc, &argv);
/*create a new window*/
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(window,"delete-event",
G_CALLBACK(delete_event),
NULL);
g_signal_connect(window, "destroy",
G_CALLBACK(destory),
NULL);
/*Sets the border width of the window*/
gtk_container_set_border_width(GTK_CONTAINER(window), 20);
/*Creates a new button with the label "Hello World"*/
button = gtk_button_new_with_label("Hello World!");
g_signal_connect(button, "clicked",
G_CALLBACK(hello),
Null);
G_CALLBACK(gtk_window_destroy),
window);
g_container_add(GTK_CONTAINER(window), button);
/*final step - display newly created widget*/
gtk_widget_show(button);
/*display window*/
gtk_widget_show(window);
gtk_main();
reutrn 0;
}
with this in cygwin
$ gcc helloworldgtksteps.c -o helloworld `pkg-config --cflags --libs gtk+-2.0`
helloworldgtksteps.c:15:9: error: expected declaration specifiers or ‘...’ before ‘Gdk’
helloworldgtksteps.c: In function ‘delete_event’:
helloworldgtksteps.c:26:9: error: ‘true’ undeclared (first use in this function)
helloworldgtksteps.c:26:9: note: each undeclared identifier is reported only once for each function it appears in
helloworldgtksteps.c: In function ‘main’:
helloworldgtksteps.c:66:2: error: ‘destory’ undeclared (first use in this function)
helloworldgtksteps.c:79:2: error: ‘Null’ undeclared (first use in this function)
helloworldgtksteps.c:88:2: error: ‘gtk_window_destroy’ undeclared (first use in this function)
helloworldgtksteps.c:118:2: error: ‘reutrn’ undeclared (first use in this function)
helloworldgtksteps.c:118:9: error: expected ‘;’ before numeric constant
I think its to do with paths which i dont know how to configure. I have a system path set to C:\gtk\bin\ but thats it. I am totally lost and a total newb.
Side note:
when i try ./confirgure - i get no such file or directory. I have pkg-config and all the rest of the packages i need.
Cheers.
|