1
如果我的FreeBSD靜態8歲以下的鏈接一個GTK +程序,gtk_builder_add_from_file()
突然返回錯誤:格萊德和靜態鏈接
Invalid object type `GtkWindow'
如何解決呢?動態鏈接一切工作正常。
更新:
cc -o foobar foo.o bar.o main.o -Wall -pedantic -std=c99 D_THREAD_SAFE -DORBIT2=1 -D_REENTRANT -I/usr/local/include/gtk-2.0 -I/usr/local/lib/gtk-2.0/include -I/usr/local/include/atk-1.0 -I/usr/local/include/cairo -I/usr/local/include/pango-1.0 -I/usr/local/include -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include -I/usr/local/include/pixman-1 -I/usr/local/include/freetype2 -I/usr/local/include/gconf/2 -I/usr/local/include/orbit-2.0 -I/usr/local/include/dbus-1.0 -I/usr/local/include/dbus-1.0/include -DGTK_DISABLE_DEPRECATED=1 -DGDK_DISABLE_DEPRECATED -DGDK_PIXBUF_DISABLE_DEPRECATED -DG_DISABLE_DEPRECATED=1 -DGTK_MULTIHEAD_SAFE=1 -export-dynamic -static -pthread -L/usr/local/lib -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lgio-2.0 -lXinerama -lXi -lXcursor -lXcomposite -lXdamage -lpangoft2-1.0 -lXext -lXfixes -lcairo -lpixman-1 -lpng -lxcb-render-util -lXrender -lxcb-render -lX11 -lxcb -lXau -lXdmcp -lpango-1.0 -lfontconfig -lexpat -lfreetype -lz -lgconf-2 -lORBit-2 -lm -ldbus-1 -lgmodule-2.0 -lgthread-2.0 -lgobject-2.0 -lglib-2.0 -liconv -lintl -lpcre
或者換句話說,在Makefile中我有:
CFLAGS := -Wall -pedantic -std=c99 LDFLAGS := -export-dynamic -static CFLAGS += $(shell pkg-config --cflags gtk+-2.0 gconf-2.0) \ -DGTK_DISABLE_DEPRECATED=1 -DGDK_DISABLE_DEPRECATED \ -DGDK_PIXBUF_DISABLE_DEPRECATED -DG_DISABLE_DEPRECATED=1 \ -DGTK_MULTIHEAD_SAFE=1 LDFLAGS += $(shell pkg-config --libs --static gtk+-2.0 gconf-2.0) -lintl -lpcre ... $(NAME): $(OBJ) cc -o [email protected] $^ $(CFLAGS) $(LDFLAGS)