我已经为我的 powerpc 目标板安装了带有 directFB 后端的 GTK+- 2.10.14,我可以在我的目标板上运行示例应用程序并看到 gui 出现在目标 LCD 中。我开始使用 glade 创建 GUI 但在工作时在 Glade 上创建我自己的 GUI 我发现 glade 需要 gtkbuildet 来编译一个 .glade 文件。gtkbuilder 从版本 GTK+-2.12.0 可用,因此再次安装 GTK+-2.12.0 和本教程中所说的休闲程序。
我的程序如下:
#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
请帮助我摆脱这个错误。