簡體   English   中英

如何調試鏈接器錯誤? 靜態鏈接ICU時獲取未定義的引用錯誤

[英]How to debug linker errors? Getting undefined reference errors when statically linking ICU

我已經為ICU 49和50構建了靜態庫,但是當與其中任何一個鏈接時,我仍然會得到667個鏈接器錯誤,如下所示。 我該如何處理調試並找出問題所在? ICU支持名單根本沒有提供任何幫助。

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我看到:

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

這讓我相信(但我不是專家)這些函數實際上是在具有正確名稱的靜態庫中定義的(從底部開始的第二行,注意它與粘貼錯誤底部的缺失符號的名稱相匹配) 。)

我定義了U_STATIC_IMPLEMENTATION = 1,我嘗試在clang和gcc下編譯49和50。 我在ubuntu x64系統上。 當我在構建靜態庫之后進行檢查時,它會通過所有測試。 我不知道如何繼續。 我可以嘗試任何想法嗎?

如果您正在處理靜態庫,則可能是鏈接順序問題。

嘗試以相反的依賴順序使用.a libs調用鏈接器。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM