我将使用 ICU4C unicode 库,版本为 4.2.1(打包在 Ubuntu 10.04 中的版本)。我做了一个简单的测试代码;只是打开一个正则表达式对象。
#include <stdio.h>
#include <unicode/utypes.h>
#include <unicode/uregex.h>
int main() {
UChar zPattern[4] = {'a', 'b', 'c', 0};
UErrorCode status = 0;
URegularExpression *pExpr = uregex_open(zPattern, -1, 0, 0, &status);
return status;
};
我使用动态链接的 icu 库编译并运行,如下所示:
gcc -o test.out test.c -licui18n -licuuc -licudata -lpthread -lm
./test.out
结果状态码为“0”。像魅力一样工作。
现在我决定像下面一样静态链接icu库,然后运行
gcc -o test.out -DU_STATIC_IMPLEMENTATION test.c -lsicui18n -lsicuuc -lsicudata -lpthread -lstdc++ -lm
./test.out
结果状态码为“1”。uregex_open 函数失败,状态码为“U_ILLEGAL_ARGUMENT_ERROR”。
我是否错过了静态链接 ICU4C 的内容?