构建库时对"utf8_nextCharSafeBody_48"ICU4C 的未定义引用

undefined reference to `utf8_nextCharSafeBody_48' icu4c while building a library

本文关键字:ICU4C 未定义 引用 nextCharSafeBody utf8 构建      更新时间:2023-10-16

我试图构建stmd库(http://getassoc.cs.nii.ac.jp/package/stmd-1.1.5.tar.gz)在Ubuntu 12.04.2 amd64上使用ICU库。我已经从Ubuntu存储库安装了libicu-dev(版本:48),并使用以下配置。

./configure --with-icu-config=/usr/bin/icu-config --with-defaultstemmer=SNOWBALL --enable-snowball=yes --enable-kill3number=yes

然后,

make

我犯了以下错误。。

/bin/bash ./libtool --mode=link g++ -I. -g -O2 -Wall -Wno-parentheses -Wdeclaration-after-   statement -g -O -D_BSD_SOURCE -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 '-DDEFAULT_STEMMER=SNOWBALL' '-DSTMD_MYSTEMMER_DIR="/usr/local/bin"' -g -Wall -O2 -Wall -ansi -pedantic -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -Wno-long-long    -D_REENTRANT  -I/usr/include  '-DUSE_SNOWBALL=1' -I/usr/local/include -DKILL3NUMBER=1  -L/usr/lib   -ldl -lm   -L/usr/lib -licui18n -licuuc -licudata  -ldl -lm    -L/usr/local/lib -o stmd stmd.o stmc.o sigflg.o nio.o -L.  -L/usr/lib   -ldl -lm   -L/usr/lib -licui18n -licuuc -licudata  -ldl -lm    -L/usr/local/lib -lystem -lstemmer -lexpat -ldl 
libtool: link: g++ -I. -g -O2 -Wall -Wno-parentheses -Wdeclaration-after-statement -g -O -D_BSD_SOURCE -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 -DDEFAULT_STEMMER=SNOWBALL -DSTMD_MYSTEMMER_DIR="/usr/local/bin" -g -Wall -O2 -Wall -ansi -pedantic -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -Wno-long-long -D_REENTRANT -I/usr/include -DUSE_SNOWBALL=1 -I/usr/local/include -DKILL3NUMBER=1 -o stmd stmd.o stmc.o sigflg.o nio.o  -L/usr/lib -L/usr/local/lib -L/home/kobkrit/stmd-1.1.5 -licui18n -licuuc -licudata -lm -lystem -lstemmer /usr/lib/x86_64-linux-gnu/libexpat.so -ldl
/home/kobkrit/stmd-1.1.5/libystem.a(normalizer.o): In function `utf8toutf16':
/home/kobkrit/stmd-1.1.5/normalizer.c:177: undefined reference to `utf8_nextCharSafeBody_48'
/home/kobkrit/stmd-1.1.5/normalizer.c:191: undefined reference to `u_errorName_48'
/home/kobkrit/stmd-1.1.5/libystem.a(normalizer.o): In function `utf16toutf8':
/home/kobkrit/stmd-1.1.5/normalizer.c:227: undefined reference to `u_errorName_48'
/home/kobkrit/stmd-1.1.5/normalizer.c:219: undefined reference to `utf8_appendCharSafeBody_48'
/home/kobkrit/stmd-1.1.5/normalizer.c:223: undefined reference to `utf8_appendCharSafeBody_48'
/home/kobkrit/stmd-1.1.5/libystem.a(normalizer.o): In function `normalizer_sparse_tostr':
/home/kobkrit/stmd-1.1.5/normalizer.c:125: undefined reference to `unorm_normalize_48'
/home/kobkrit/stmd-1.1.5/normalizer.c:138: undefined reference to `unorm_normalize_48'
/home/kobkrit/stmd-1.1.5/normalizer.c:140: undefined reference to `u_errorName_48'
/home/kobkrit/stmd-1.1.5/libystem.a(ngram.o): In function `nextchar':
/home/kobkrit/stmd-1.1.5/ngram.c:158: undefined reference to `utf8_nextCharSafeBody_48'
/home/kobkrit/stmd-1.1.5/ngram.c:150: undefined reference to `utf8_nextCharSafeBody_48'
/home/kobkrit/stmd-1.1.5/libystem.a(ngram.o): In function `ng_output':
/home/kobkrit/stmd-1.1.5/ngram.c:182: undefined reference to `utf8_appendCharSafeBody_48'
collect2: ld returned 1 exit status
make: *** [stmd] Error 1

这似乎是关于链接器到ICU库之间的问题,所以我查看了Makefile,我发现了

...
CFLAGS+=$(shell /usr/bin/icu-config --cflags)
CFLAGS+=$(shell /usr/bin/icu-config --cppflags)
LDFLAGS+=$(shell /usr/bin/icu-config --ldflags-searchpath)
LDFLAGS+=$(shell /usr/bin/icu-config --ldflags)
...
(I don't quite sure, does it relate to the problem or not?)

我试着在Ubuntu 10.04.4 LTS amd64上构建stmd库,它运行得很好。但遗憾的是,我的服务器硬件与旧的Ubuntu不兼容。请帮忙。

您的命令行:

g++ ... -licui18n -licuuc -licudata  -ldl -lm ... -o stmd stmd.o stmc.o ...

不正确:命令行中对象文件和库的顺序很重要。