如何调试链接器错误?静态链接ICU时出现未定义的引用错误 [英] How to debug linker errors? Getting undefined reference errors when statically linking ICU

查看:42
本文介绍了如何调试链接器错误?静态链接ICU时出现未定义的引用错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为 ICU 49 和 50 构建了静态库,但是当与其中任何一个链接时,我仍然收到 667 个链接器错误,如下所示.我怎样才能调试这个并找出问题所在?ICU 支持列表根本没有提供任何帮助.

I've built the static libraries for ICU 49 and 50 but when linking with either one of them I still get 667 linker errors like the ones below. How can I approach debugging this and figuring out what the problem is? The ICU support list has offered no help at all.

clang++ -ccc-gcc-name g++ -Wl,-E -o velocity main.o city.o auto_lua.o
obj_builder.o index.o obj.o str.o db.o datetime.o msg_parser.o
task_scheduler.o gc.o global_settings.o transaction.o schema.o
skip_node.o util.o thread_context.o hashtable_base.o attr.o
page_pool.o result_buffer.o server_epoll.o logging.o test_server.o
test_main.o     -L../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.7 -lc++
-lllalloc -lluajit -ldl -lm -lrt -lboost_system -lboost_filesystem
-licuuc -licui18n -licudata -lgtest
../lib/libicui18n.a(ucol.ao): In function `uprv_new_collIterate_50':
ucol.cpp:(.text.uprv_new_collIterate_50+0x37): undefined reference to
`icu_50::UMemory::operator new(unsigned long)'
ucol.cpp:(.text.uprv_new_collIterate_50+0xd2): undefined reference to
`icu_50::UMemory::operator delete(void*)'
../lib/libicui18n.a(ucol.ao): In function `uprv_delete_collIterate_50':
ucol.cpp:(.text.uprv_delete_collIterate_50+0x2f): undefined reference
to `icu_50::UMemory::operator delete(void*)'
../lib/libicui18n.a(ucol.ao): In function `initializeFCD(UErrorCode*)':
ucol.cpp:(.text._ZL13initializeFCDP10UErrorCode+0x2c): undefined
reference to `icu_50::Normalizer2Factory::getNFCImpl(UErrorCode&)'
../lib/libicui18n.a(ucol.ao): In function `ucol_initCollator_50':
ucol.cpp:(.text.ucol_initCollator_50+0x126): undefined reference to
`utrie_unserialize_50'
../lib/libicui18n.a(ucol.ao): In function `ucol_prv_getSpecialCE_50':
ucol.cpp:(.text.ucol_prv_getSpecialCE_50+0x9f6): undefined reference
to `u_charDigitValue_50'
ucol.cpp:(.text.ucol_prv_getSpecialCE_50+0xc1f): undefined reference
to `u_charDigitValue_50'

在编译的静态库上运行 nm 我看到了这个:

Running nm on the compiled static libraries I see this:

nm -A libicu* | grep u_charDigitValue_50
libicui18n.a:unum.ao:                 U u_charDigitValue_50
libicui18n.a:decimfmt.ao:                 U u_charDigitValue_50
libicui18n.a:dcfmtsym.ao:                 U u_charDigitValue_50
libicui18n.a:ucol.ao:                 U u_charDigitValue_50
libicui18n.a:regexcmp.ao:                 U u_charDigitValue_50
libicui18n.a:rematch.ao:                 U u_charDigitValue_50
libicui18n.a:uregex.ao:                 U u_charDigitValue_50
libicui18n.a:tzfmt.ao:                 U u_charDigitValue_50
libicuuc.a:uchar.ao:0000000000000000 T u_charDigitValue_50
libicuuc.a:rbbiscan.ao:                 U u_charDigitValue_50

这让我相信(但我不是专家)这些函数实际上是在静态库中用正确的名称定义的(从底部算起第二行,注意它与底部缺少符号的名称相匹配)粘贴的错误.)

Which leads me to believe (but I'm no expert) that the functions are actually defined in the static libs with the correct names (second line from the bottom, notice it matches the name of the missing symbol at the bottom of the pasted errors.)

我定义了 U_STATIC_IMPLEMENTATION=1 并尝试在 clang 和 gcc 下编译 49 和 50.我在 ubuntu x64 系统上.当我在构建静态库后进行检查时,它通过了所有测试.我不知道如何继续.我可以尝试任何想法吗?

I defined U_STATIC_IMPLEMENTATION=1 and I tried compiling both 49 and 50 under both clang and gcc. I'm on an ubuntu x64 system. When I make check after building the static libs, it passes all tests. I'm at a loss as to how to proceed. Any ideas I can try?

推荐答案

如果您正在处理静态库,则可能是链接顺序问题.

If you're dealing with static libraries, it could be a link order problem.

尝试以相反的依赖顺序调用带有 .a 库的链接器.

Try calling the linker with the .a libs in reverse order of dependence.

这篇关于如何调试链接器错误?静态链接ICU时出现未定义的引用错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆