尝试将测试添加到gobject-introspection测试套件中,以涵盖更多功能并了解代码。 想要创建一个简单的测试来从libgirepository_internals.a创建一个对象,但链接有问题, 想知道是否有人可以就此提出一些建议?
代码在这里,https://github.com/h4ck3rm1k3/gobject-introspection它是主git的简单分支://git.gnome.org/gobject-introspection添加了一些测试。
GObjectIntrospection的项目页面为http://live.gnome.org/GObjectIntrospection
未链接的测试模块是: https://github.com/h4ck3rm1k3/gobject-introspection/blob/master/tests/repository/gitestenum.c
我所做的就是添加额外的lib:
$(top_builddir)/libgirepository-internals.la
gitestenum_SOURCES = $(srcdir)/gitestenum.c
gitestenum_CPPFLAGS = $(GIREPO_CFLAGS) -I$(top_srcdir)/girepository
gitestenum_LDADD = $(top_builddir)/libgirepository-1.0.la $(top_builddir)/libgirepository-internals.la $(top_builddir)/libgirepository-gthash.la $(GIREPO_LIBS)
这是编译器错误:
CCLD gitestenum
../../.libs/libgirepository-internals.a(libgirepository_internals_la-girnode.o): In function `_g_ir_node_get_full_size_internal':
gobject-introspection/girepository/girnode.c:629: undefined reference to `g_type_tag_to_string'
../../.libs/libgirepository-internals.a(libgirepository_internals_la-girnode.o): In function `serialize_type':
gobject-introspection/girepository/girnode.c:1198: undefined reference to `g_type_tag_to_string'
../../.libs/libgirepository-internals.a(libgirepository_internals_la-girmodule.o): In function `_g_ir_module_build_typelib':
gobject-introspection/girepository/girmodule.c:548: undefined reference to `g_typelib_new_from_memory'
../../.libs/libgirepository-internals.a(libgirepository_internals_la-giroffsets.o): In function `get_type_size_alignment':
gobject-introspection/girepository/giroffsets.c:300: undefined reference to `gi_type_tag_get_ffi_type'
../../.libs/libgirepository-internals.a(libgirepository_internals_la-giroffsets.o): In function `get_enum_size_alignment':
gobject-introspection/girepository/giroffsets.c:174: undefined reference to `g_type_tag_to_string'
../../.libs/libgirepository-internals.a(libgirepository_internals_la-giroffsets.o): In function `get_type_size_alignment':
gobject-introspection/girepository/giroffsets.c:311: undefined reference to `g_type_tag_to_string'
困扰我的是符号在那里:
gobject-introspection/.libs$ nm libgirepository-1.0.so | grep g_type_tag_to_string
0000f0c0 T g_type_tag_to_string
gobject-introspection/.libs$ nm libgirepository-1.0.a | grep g_type_tag_to_string
U g_type_tag_to_string
00001e00 T g_type_tag_to_string
U g_type_tag_to_string
这是内部链接器命令
/usr/lib/gcc/i686-linux-gnu/4.6.1/collect2 --build-id --no-add-needed --as-needed --eh-frame-hdr -m elf_i386 --hash-style=gnu -dynamic-linker /lib/ld-linux.so.2 -z relro -o .libs/gitestenum /usr/lib/gcc/i686-linux-gnu/4.6.1/../../../i386-linux-gnu/crt1.o /usr/lib/gcc/i686-linux-gnu/4.6.1/../../../i386-linux-gnu/crti.o /usr/lib/gcc/i686-linux-gnu/4.6.1/crtbegin.o -L/usr/lib/gcc/i686-linux-gnu/4.6.1 -L/usr/lib/gcc/i686-linux-gnu/4.6.1/../../../i386-linux-gnu -L/usr/lib/gcc/i686-linux-gnu/4.6.1/../../../../lib -L/lib/i386-linux-gnu -L/lib/../lib -L/usr/lib/i386-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/i686-linux-gnu/4.6.1/../../.. gitestenum-gitestenum.o --export-dynamic ../../.libs/libgirepository-1.0.so ../../.libs/libgirepository-internals.a -lm -ldl /usr/lib/i386-linux-gnu/libgio-2.0.so /usr/lib/i386-linux-gnu/libgmodule-2.0.so -lffi /usr/lib/i386-linux-gnu/libgobject-2.0.so /usr/lib/i386-linux-gnu/libgthread-2.0.so -lrt /usr/lib/i386-linux-gnu/libglib-2.0.so -lgcc --as-needed -lgcc_s --no-as-needed -lpthread -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/i686-linux-gnu/4.6.1/crtend.o /usr/lib/gcc/i686-linux-gnu/4.6.1/../../../i386-linux-gnu/crtn.o
感谢, 麦克
此邮件已发布到邮件列表:gtk-devel-list@gnome.org,但正在等待审核,我在此处发布以获取快速帮助。
此消息已发布到gtk devel list http://mail.gnome.org/archives/gtk-devel-list/2012-March/msg00060.html
答案 0 :(得分:1)
已解决,是#-export-symbols-regex' ^ gi?_' 代码在此处提交https://github.com/h4ck3rm1k3/gobject-introspection/commit/9dc11f8a42e66797db7ed015ac5f2703435f4456