Gtkbuilder错误

时间:2013-02-15 15:29:32

标签: gtk

我已经为我的powerpc目标板安装了带有directFB后端的GTK + - 2.10.14,我能够在我的目标板上运行示例应用程序并看到gui出现在目标LCD中。我开始使用glade创建GUI但是在使用Glade创建我自己的GUI时,我发现glade需要gtkbuildet来编译.glade文件。 gtkbuilder可以从版本GTK + -2.12.0获得,因此再次安装了GTK + -2.12.0并且允许程序在this tutorial中说明。

我的节目如下:

#include<gtk/gtk.h>

int
main( int    argc,char **argv )
{

GtkBuilder *builder;
GtkWidget  *window;
GError     *error = NULL;

/* Init GTK+ */
gtk_init( &argc, &argv );

/* Create new GtkBuilder object */
builder = gtk_builder_new();
/* Load UI from file. If error occurs, report it and quit application.
*      * Replace "tut.glade" with your saved project. */
if( ! gtk_builder_add_from_file( builder, "graph.glade", &error ) )
    {
        g_warning( "%s", error->message );
        g_free( error );
        return( 1 );
    }

/* Get main window pointer from UI */
window = GTK_WIDGET( gtk_builder_get_object( builder, "window1" ) );

/* Connect signals */
gtk_builder_connect_signals( builder, NULL );

/* Destroy builder, since we don't need it anymore */
g_object_unref( G_OBJECT( builder ) );

/* Show window. All other widgets are automatically shown by GtkBuilder */
gtk_widget_show( window );

/* Start main loop */
gtk_main();

return( 0 );
}

现在当我编译上面的程序时,我遇到了如下错误:

powerpc-linux-gnu-gcc progressbar.c -o progressbar -pthread -I/opt/gtkdfb/usr/local/include/glib-2.0 -I/opt/gtkdfb/usr/local/lib/glib-2.0/include -I/opt/gtkdfb/usr/local/include/pango-1.0 -I/opt/gtkdfb/usr/local/include/cairo -I/opt/gtkdfb/usr/local/include -I/opt/gtkdfb/usr/local/freetype2 -I/opt/gtkdfb/usr/local/libpng12 -I/opt/gtkdfb/usr/local/includegtk-2.0 -D_REENTRANT -D_GNU_SOURCE -I/opt/gtkdfb/usr/include/directfb -L/opt/gtkdfb/usr/local/lib  -ldirectfb -lfusion -ldirect -lpthread -ldl -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lxml2 -lpng12 -lgthread-2.0 -lgtk-directfb-2.0 -lffi -lz -lm `pkg-config gtk+-2.0 --cflags --libs`

/tmp/ccZ9fkFp.o: In function `main':

progressbar.c:(.text+0x3c): undefined reference to `gtk_builder_new'

progressbar.c:(.text+0x58): undefined reference to `gtk_builder_add_from_file'

progressbar.c:(.text+0xb0): undefined reference to `gtk_builder_get_object'

progressbar.c:(.text+0xd8): undefined reference to `gtk_builder_connect_signals'

collect2: ld returned 1 exit status

make: *** [helloworld] Error 1

请帮我解决这个错误。

2 个答案:

答案 0 :(得分:0)

如果没有GtkBuilder,则使用libglade代替。您必须使用支持GTK + 2和libglade的glade版本(3.8 branch符合要求)。

不要尝试在较新的GTK +上使用directFB后端:它由Debian安装程序的开发人员主动维护,但很久以来就被放弃了。

答案 1 :(得分:0)

我的猜测是pkg-config仍然指向旧的2.10版本。我也不明白你为什么pkg-config gtk+-2.0 --cflags --libs 也提供所有GCC命令行参数。这应该是pkg-config的工作。