Compiling the icu sqlite extension statically linked to icu

為{幸葍}努か 提交于 2019-12-04 22:35:34

问题


I want to compile the icu sqlite extension statically linked to icu.

This is what I've tried, maybe the mistake is obvious to you.

> cd icu/source
> ./runConfigureIcu Linux --enable-static --with-packaging-format=archive
...
> make

> cd ../../icu-sqlite
> gcc -o libSqliteIcu.so -shared icu.c -I../icu/source/common
      -I../icu/source/i18n -L ../icu/source/lib -lsicuuc -lsicui18n -lsicudata
...
> sqlite3
> .load "libSqliteIcu.so"
Undefined symbol utf8_countTrailBytes

Files

icu sqlite extension

Download icu.c from sqlite.org

ICU 4.2.1

Download ICU4C from icu-project.org

My Requirements

  • Runs on Linux & Windows
  • Only one file that I have to distribute: libSqliteIcu.so.

Any idea what else I can try?

Documentation

  • Sqlite ICU extension's readme
  • ICU's readme

回答1:


This command line worked for me on Linux:

g++ -shared --language c  -o libSqliteIcu.so icu.c  -I../icu/source/common -I../icu/source/i18n -lpthread -lm   -L../icu/source/lib -lsicui18n -lsicuuc -lsicudata  -lpthread -lm 

Notice the ordering of the library files, and the use of g++ to make sure the c++ runtime is referenced even though we're compiling a C file.

NB. I used the output of icu-config --prefix=../icu/source --ldflags.




回答2:


I ran into the same problem as you. You can edit icu\include\utf8.h and replace following lines

          #ifdef U_UTF8_IMPL
          U_EXPORT const uint8_t 
          #elif defined(U_STATIC_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION)
          U_CFUNC const uint8_t
          #else
          U_CFUNC U_IMPORT const uint8_t /* U_IMPORT2? */ /*U_IMPORT*/ 
          #endif
          utf8_countTrailBytes[256];

with

              const uint8_t countTrailBytes[256];

This should do the trick.



来源:https://stackoverflow.com/questions/1818678/compiling-the-icu-sqlite-extension-statically-linked-to-icu

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!