- 論壇徽章:
- 5
|
回復 12# FightForWin
還是你V5,include 絕對路徑
==================for example===============
1)下載icu4c:wget http://download.icu-project.org/ ... icu4c-4_6_1-src.tgz
2)解包,編譯,安裝
2.1) ./configure --prefix=/opt/gtk3 --enable-icuio=no --enable-extras=no --enable-layout=no --enable-tests=no --enable-samples=no
用不到的功能disable了
2.2)make 然后 make install
3)配置環(huán)境
3.1)export PKG_CONFIG_PATH=/opt/gtk3/lib/pkgconfig
3.2)export LD_LIBRARY_PATH=/opt/gtk3/lib
/opt/gtk3請用configure時指定的 --prefix 替換
3.3)測試環(huán)境
pkg-config --cflags --libs icu-i18n 應該有如下輸出:-I/opt/gtk3/include -L/opt/gtk3/lib -licui18n -licuuc -licudata
4)編寫測試代碼- #include <string.h>
- #include <unicode/utypes.h>
- #include <unicode/ucsdet.h>
- #include <unicode/ucnv.h>
- #include <unicode/ustring.h>
- int main (int argc, char *argv[])
- {
- UErrorCode status = U_ZERO_ERROR;
- UCharsetDetector *csd;
- const UCharsetMatch *match;
- const char *name;
- const char *text = "我的代碼該怎樣去引用 我編譯安裝好的icu庫呢? 我編譯錯誤一大堆。";
- csd = ucsdet_open (&status);
- ucsdet_setText (csd, text, strlen (text), &status);
- if (U_FAILURE(status))
- {
- fprintf(stderr, "error: %s\n", u_errorName (status));
- ucsdet_close (csd);
- return -1;
- }
- match = ucsdet_detect (csd, &status);
- if (!match)
- {
- fprintf(stderr, "detect failed\n");
- ucsdet_close (csd);
- return -1;
- }
-
- name = ucsdet_getName (match, &status);
- printf("detected coding: %s\n", name);
- ucsdet_close (csd);
- return 0;
- }
復制代碼 5)編譯(就這一個文件,犯不著makefile)
gcc -o test `pkg-config --cflags --libs icu-i18n` test.c
6)測試
./test 打。篸etected coding: UTF-8
7)over |
|