【问题标题】:undefined reference to `utf8_nextCharSafeBody_48' icu4c while building a library构建库时未定义对“utf8_nextCharSafeBody_48”icu4c 的引用
【发布时间】:2013-07-06 10:48:17
【问题描述】:

我尝试在使用 ICU 库的 Ubuntu 12.04.2 amd64 上构建 stmd 库 (http://getassoc.cs.nii.ac.jp/package/stmd-1.1.5.tar.gz)。 我已经从 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 不兼容。请帮忙。

【问题讨论】:

  • 我已经尝试过旧版本的 icu,例如 icu46、icu42 和 icu36,但仍然出现这些错误。

标签: c++ linker makefile icu


【解决方案1】:

你的命令行:

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

不正确:目标文件和库在命令行matters的顺序。

【讨论】:

    猜你喜欢
    • 2018-09-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-09
    • 2017-05-09
    • 1970-01-01
    相关资源
    最近更新 更多