![](/img/trans.png)
[英]Can't compile shared library under Windows due to undefined reference
[英]Can't compile with ICU library - undefined reference to 'u_strlen_3_6'
嘗試使ICU庫與我的C程序一起使用,以便我可以將UTF-8字符串轉換為小寫。 這是將重現編譯錯誤的最小示例:
main.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unicode/ustring.h>
int main(int argc, char **argv)
{
UChar test[100] = { 0x41, 0x42, 0x43, 0x20, 0xc6, 0xd8, 0xc5, 0x20, 0xc9, 0x20, 0xc8, 0x20, 0xd1, 0x20, 0xca, 0x20, 0xd6 };
for (int i = 0; i < u_strlen(test); i++){
printf("%d\n", i);
}
}
生成文件
CC = gcc
CFLAGS = -g -O3 -std=c99
GNUCFLAGS = -g -O3 -std=gnu99 -lm
main: obj/main.o
$(CC) $(CFLAGS) -o bin/main obj/main.o
obj/main.o: src/main.c
$(CC) $(CFLAGS) -c src/main.c -o obj/main.o
編譯器輸出
gcc -g -O3 -std=c99 -o bin/main obj/main.o
obj/main.o: In function `main':
~/src/main.c:9: undefined reference to `u_strlen_3_6'
collect2: error: ld returned 1 exit status
Makefile:6: recipe for target 'main' failed
make: *** [main] Error 1
我試過包括http://icu-project.org/apiref/icu4c/列出的所有頭文件,但是沒有運氣。 還嘗試將-licudata -licui18n -licuio -liculx -licutest -licutu -licuuc
到Makefile-相同的錯誤。
我在Debian GNU / Linux 8.5(jessie)上安裝了以下軟件包:
有什么建議么?
我認為您需要#include <unicode/utypes>.
但是您應該能夠通過搜索頭文件來找出哪個定義了u_strlen_3_6,從而找出需要哪個Unicode包含文件。
您可能還需要在makefile中的CFLAGS參數中添加-I。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.