LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Can't compile sample GTK app (https://www.linuxquestions.org/questions/linux-software-2/can%27t-compile-sample-gtk-app-346791/)

slackwarefan 07-25-2005 11:50 PM

Can't compile sample GTK app
 
There seems to be something wrong with either GCC or with GTK. I recently tried to compile the sample GTK application in a programming book I got, but it will not compile. It complains about do_click being undeclared, though it should be declared in gtk.h.

I'd been able to compile GTK programs with the same function doing the exact same thing before, so I don't know what's wrong.

Here's the program.
#include <stdio.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>

int main(int argc, char *argv[]){
GtkWidget *window, *button;

int count = 0;

gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
//gtk_container_border_width(GTK_CONTAINER(window), 5);
button = gtk_button_new_with_label("Click to increment counter");
gtk_signal_connect(GTK_OBJECT(button), "clicked",
GTK_SIGNAL_FUNC(do_click), &count);
gtk_container_add(GTK_CONTAINER(window), button);



gtk_widget_show(button);
gtk_widget_show(window);

gtk_main();

return 0;
}

GCC 3.3.4 GTK +- 2.0

Matir 07-26-2005 01:10 AM

What is the entire error message?

slackwarefan 07-26-2005 01:20 AM

14 Error: do_click undeclared (first use in this function)
14 Error: (Each undeclared identifier is declared only
14 Error: once for each function it appears in.)

Matir 07-26-2005 01:32 AM

I don't find a do_click in my gtk.h and related files. Where did you find this sample?

slackwarefan 07-26-2005 12:37 PM

The book is "Linux Programming 2nd edition UNLEASHED"

I see you may be right. I just looked at the tutorial on gtk.org and they did the same program differently.

Matir 07-26-2005 07:57 PM

I wonder if that book may be thinking gtk-1.2? I haven't looked in those header files, just gtk2 since that is what you specified above.


All times are GMT -5. The time now is 09:30 AM.