|
我是个编程自学者。用VB写过一点程序。 用VBA,为EXCEL和CAD的自动化办公,写了不少东西。
我会一点C,想用gtk 在 windows XP 下编程。
可是装了mingw 和 gtk , 编译不成功。
mingw 装的是当前 的stable版,gcc是3.4.5的。 设了path 路径。编译一个hello world, 成功了。
gtk+ 装的是gtk+-bundle_2.16.1-20090419_win32.zip 。装完了,也设了个path路径。
编译下面这段程序:- #include <gtk/gtk.h>
- static gboolean delete_event( GtkWidget *widget, GdkEvent *event, gpointer data )
- {
- g_print ("delete event occurred\n");
- return FALSE;
- }
- static void destroy( GtkWidget *widget, gpointer data )
- {
- gtk_main_quit ();
- }
- int main( int argc, char *argv[] )
- {
- GtkWidget *window;
- GtkWidget *label;
- gtk_init (&argc, &argv);
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (delete_event), NULL);
- g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (destroy), NULL);
- label = gtk_label_new ("Hello GTK");
- gtk_container_add (GTK_CONTAINER (window), label);
- gtk_container_set_border_width (GTK_CONTAINER (window), 10);
- gtk_widget_show (label);
- gtk_widget_show (window);
- gtk_main ();
- return 0;
- }
复制代码
编译命令和出错信息如下:- E:\temp>mingw32-gcc -g -mms-bitfields -Ie:/mingw/include -Ie:/gtk/include/gtk-2.0 -Ie:/gtk/lib/gtk-2.0/include -Ie:/gtk
- include/atk-1.0 -Ie:/gtk/include/cairo -Ie:/gtk/include/pango-1.0 -Ie:/gtk/include/glib-2.0 -Ie:/gtk/lib/glib-2.0/inclu
- e -Ie:/gtk/include/libpng12 -Le:/mingw/lib -Le:/gtk/lib -lgtk-win32-2.0 -lgdk-win32-2.0 -latk-1.0 -lgio-2.0 -lgdk_pixb
- f-2.0 -lpangowin32-1.0 -lgdi32 -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lintl test
- c
- C:\DOCUME~1\Lixw\LOCALS~1\Temp/cchUZViZ.o: In function `expose_event_callback':
- E:/temp/test.c:19: undefined reference to `gtk_widget_get_style'
- E:/temp/test.c:21: undefined reference to `gdk_draw_rectangle'
- C:\DOCUME~1\Lixw\LOCALS~1\Temp/cchUZViZ.o: In function `change_color_callback':
- E:/temp/test.c:39: undefined reference to `gtk_color_selection_dialog_new'
- E:/temp/test.c:41: undefined reference to `gtk_window_get_type'
- E:/temp/test.c:41: undefined reference to `g_type_check_instance_cast'
- E:/temp/test.c:41: undefined reference to `gtk_window_get_type'
- E:/temp/test.c:41: undefined reference to `g_type_check_instance_cast'
- E:/temp/test.c:41: undefined reference to `gtk_window_set_transient_for'
- E:/temp/test.c:43: undefined reference to `gtk_color_selection_get_type'
- E:/temp/test.c:43: undefined reference to `gtk_color_selection_dialog_get_type'
- E:/temp/test.c:43: undefined reference to `g_type_check_instance_cast'
- E:/temp/test.c:43: undefined reference to `g_type_check_instance_cast'
- E:/temp/test.c:45: undefined reference to `gtk_color_selection_set_previous_color'
- E:/temp/test.c:46: undefined reference to `gtk_color_selection_set_current_color'
- E:/temp/test.c:47: undefined reference to `gtk_color_selection_set_has_palette'
- E:/temp/test.c:49: undefined reference to `gtk_dialog_get_type'
- E:/temp/test.c:49: undefined reference to `g_type_check_instance_cast'
- E:/temp/test.c:49: undefined reference to `gtk_dialog_run'
- E:/temp/test.c:53: undefined reference to `gtk_color_selection_get_current_color'
- E:/temp/test.c:56: undefined reference to `gtk_widget_modify_bg'
- E:/temp/test.c:59: undefined reference to `gtk_widget_destroy'
- C:\DOCUME~1\Lixw\LOCALS~1\Temp/cchUZViZ.o: In function `do_colorsel':
- E:/temp/test.c:75: undefined reference to `gtk_window_new'
- E:/temp/test.c:76: undefined reference to `gtk_widget_get_screen'
- E:/temp/test.c:76: undefined reference to `gtk_window_get_type'
- E:/temp/test.c:76: undefined reference to `g_type_check_instance_cast'
- E:/temp/test.c:76: undefined reference to `gtk_window_set_screen'
- E:/temp/test.c:78: undefined reference to `gtk_window_get_type'
- E:/temp/test.c:78: undefined reference to `g_type_check_instance_cast'
- E:/temp/test.c:78: undefined reference to `gtk_window_set_title'
- E:/temp/test.c:80: undefined reference to `gtk_widget_destroyed'
- E:/temp/test.c:80: undefined reference to `g_signal_connect_data'
- E:/temp/test.c:83: undefined reference to `gtk_container_get_type'
- E:/temp/test.c:83: undefined reference to `g_type_check_instance_cast'
- E:/temp/test.c:83: undefined reference to `gtk_container_set_border_width'
- E:/temp/test.c:85: undefined reference to `gtk_vbox_new'
- E:/temp/test.c:86: undefined reference to `gtk_container_get_type'
- E:/temp/test.c:86: undefined reference to `g_type_check_instance_cast'
- E:/temp/test.c:86: undefined reference to `gtk_container_set_border_width'
复制代码 出错信息很多,只贴出来一段。基本上是所有的gtk函数都没有找到。
请高手帮忙解答,为什么找不到函数参考。 |
|