ubuntu下icu4c编译及测试

来源:互联网 发布:苹果去广告软件 编辑:程序博客网 时间:2024/05/22 10:56

ubuntu下icu4c编译及测试

 

1 登录icu官方网站http://icu-project.org/apiref/icu4c/index.html

  找到download链接http://site.icu-project.org/download下载源码。

  点icu4.6进到一个新的页面 找到ICU4C Source Code Download 下载for unix的那个。

2 下载后解压。编译方法载readme.html中。

3 本人实验过程如下:

  解压后,打开终端cd 到icu的source目录。

  一般有configure文件的都先运行 ./configure命令之后就会出现make file文件。然后make就可以了。

  但是这里直接./configure会提示权限不够。 运行sudo ./configure会提示找不到命令。

4 正确方法如下: 先运行命令 chmod +x runConfigureICU configure install-sh 

5 运行./configure

6 make

7 若要安装到系统中 运行sudo make install.

8写个测试程序

 

  //icutest.c

//optimist_liu

 

#include <stdio.h>

#include <string.h>

#include <stdlib.h>

 

#include <unicode/utypes.h>

#include <unicode/ucol.h>

#include <unicode/ustring.h>

#include<unicode/coll.h>

int main(void)

{

 

UErrorCode success;

Collator *myCollator = Collator::createInstance(success);

if(myCollator->compare("abc","ABC")<0)

{

  printf("abc is less than ABC/n");

}

else

{

  printf("abc is greater than ABC");

}

 

 

return 0;

}

 

9 保存。

10 编译。因为此处用到了Collator类,所以用c++的编译方法 g++ icutest.c  -o test  -licuio

11 运行./test后会提示找不到library

12 解决问题加环境变量  export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

13 ./test 成功输出abc is less than ABC

原创粉丝点击