开发者

static linking ICU4C makes uregex functions fail

I am going to use ICU4C unicode library with version 4.2.1 (the version which is packaged in Ubuntu 10.04). I made a simple test code; just opening a regular expression object.

#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, &a开发者_如何学JAVAmp;status);
    return status;
};

I compiled with dynamically-linked icu library and ran, like below:

gcc -o test.out test.c -licui18n -licuuc -licudata -lpthread -lm
./test.out

and the result status code was '0'. worked like a charm.

Now I decided to link icu library statically like below, and ran

gcc -o test.out -DU_STATIC_IMPLEMENTATION test.c -lsicui18n -lsicuuc -lsicudata -lpthread -lstdc++ -lm
./test.out

and the result status code was '1'. uregex_open function failed with the status code 'U_ILLEGAL_ARGUMENT_ERROR'.

Did I missed something to link ICU4C statically?


Check the libsicudata you ended up hitting- it's probably the 'stub' one. If you want ICU's data to be loaded as a static library, it should be a several-meg libicusdata.

To debug ICU loading issues, call u_init(&status) first, that will see if ICU can load its data. I don't know how ubuntu builds ICU, maybe the data is loaded in a different way (such as from a file).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜