hello,
I'm OuYang from China.
I write a program about gtk form. When I use the way of automake to
compile it, error is out.
Following the letter, there is my file
[EMAIL PROTECTED]:~/testdlg$ make
cd . && /bin/bash /home/ouyang/testdlg/missing --run aclocal-1.7
cd . && \
/bin/bash /home/ouyang/testdlg/missing --run automake-1.7 --gnu
Makefile
cd . && /bin/bash /home/ouyang/testdlg/missing --run autoconf
/bin/bash ./config.status --recheck
running CONFIG_SHELL=/bin/bash /bin/bash ./configure --no-create
--no-recursion
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
configure: creating ./config.status
cd . && /bin/bash ./config.status Makefile depfiles
config.status: creating Makefile
config.status: executing depfiles commands
cd . && /bin/bash /home/ouyang/testdlg/missing --run autoheader
touch ./config.h.in
cd . && /bin/bash ./config.status config.h
config.status: creating config.h
config.status: config.h is unchanged
make all-am
make[1]: Entering directory `/home/ouyang/testdlg'
if gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -MT calculate.o -MD -MP -MF
".deps/calculate.Tpo" \
-c -o calculate.o `test -f 'calculate.c' || echo './'`calculate.c; \
then mv -f ".deps/calculate.Tpo" ".deps/calculate.Po"; \
else rm -f ".deps/calculate.Tpo"; exit 1; \
fi
calculate.c:1:21: error: gtk/gtk.h: No such file or directory
calculate.c:3: error: expected '=', ',', ';', 'asm' or '__attribute__' before
'count'
calculate.c:6: error: expected ')' before '*' token
calculate.c:14: error: expected ')' before '*' token
calculate.c: In function 'main':
calculate.c:24: error: 'GtkWidget' undeclared (first use in this function)
calculate.c:24: error: (Each undeclared identifier is reported only once
calculate.c:24: error: for each function it appears in.)
calculate.c:24: error: 'label' undeclared (first use in this function)
calculate.c:25: error: 'window' undeclared (first use in this function)
calculate.c:26: error: 'frame' undeclared (first use in this function)
calculate.c:27: error: 'plus' undeclared (first use in this function)
calculate.c:28: error: 'minus' undeclared (first use in this function)
calculate.c:32: error: 'GTK_WINDOW_TOPLEVEL' undeclared (first use in this
function)
calculate.c:33: error: 'GTK_WIN_POS_CENTER' undeclared (first use in this
function)
calculate.c:54: error: 'gtk_main_quit' undeclared (first use in this function)
calculate.c:54: error: 'NULL' undeclared (first use in this function)
calculate.c:57: error: 'increase' undeclared (first use in this function)
calculate.c:60: error: 'decrease' undeclared (first use in this function)
make[1]: *** [calculate.o] Error 1
make[1]: Leaving directory `/home/ouyang/testdlg'
make: *** [all] Error 2
#include <gtk/gtk.h>
gint count = 0;
char buf[5];
void increase(GtkWidget *widget, gpointer label)
{
count++;
sprintf(buf, "%d", count);
gtk_label_set_text(label, buf);
}
void decrease(GtkWidget *widget, gpointer label)
{
count--;
sprintf(buf, "%d", count);
gtk_label_set_text(label, buf);
}
int main(int argc, char** argv) {
GtkWidget *label;
GtkWidget *window;
GtkWidget *frame;
GtkWidget *plus;
GtkWidget *minus;
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
gtk_window_set_default_size(GTK_WINDOW(window), 250, 180);
gtk_window_set_title(GTK_WINDOW(window), "+-");
frame = gtk_fixed_new();
gtk_container_add(GTK_CONTAINER(window), frame);
plus = gtk_button_new_with_label("+");
gtk_widget_set_size_request(plus, 80, 35);
gtk_fixed_put(GTK_FIXED(frame), plus, 50, 20);
minus = gtk_button_new_with_label("-");
gtk_widget_set_size_request(minus, 80, 35);
gtk_fixed_put(GTK_FIXED(frame), minus, 50, 80);
label = gtk_label_new("0");
gtk_fixed_put(GTK_FIXED(frame), label, 190, 58);
gtk_widget_show_all(window);
g_signal_connect(window, "destroy",
G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect(plus, "clicked",
G_CALLBACK(increase), label);
g_signal_connect(minus, "clicked",
G_CALLBACK(decrease), label);
gtk_main();
return 0;
}
bin_PROGRAMS = calculate
calculate_SOURCES = \
calculate.c
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.61)
AC_INIT([calculate], [1.1])
AC_CONFIG_SRCDIR([calculate.c])
AM_INIT_AUTOMAKE
AC_CONFIG_HEADER([config.h])
# Checks for programs.
AC_PROG_CC
# Checks for libraries.
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AC_CONFIG_FILES([Makefile])
AC_OUTPUT