6

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

Georg Schölly
  • 124,188
  • 49
  • 220
  • 267
  • Hi gs, If you success compile and load icu module in sqlite3 in windows, would you mind sharing which compiler you use like (vc++/mingw,cygwin) and steps how you compile it? I can compile on linux with no problem, but still no success on windows yet. – YOU Dec 07 '09 at 16:18
  • I would like to see a solution for windows too. Could someone provide the necessary steps? – PeterCo Aug 18 '14 at 11:28

2 Answers2

3

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.

Amnon
  • 7,652
  • 2
  • 26
  • 34
  • The important difference seems to be that you used g++ instead of gcc. I'll try it in windows and then award you the bounty if it works. – Georg Schölly Dec 07 '09 at 08:25
  • Haven't found the time to test it yet, still, I'm awarding you the bounty because it works for Linux. – Georg Schölly Dec 08 '09 at 21:53
  • For anyone arriving through searching, this worked on Windows for me: gcc -shared icu.c -L C:\msys64\mingw64\lib -licuin -licuuc -licudt -lpthread -lm -o icu.dll, where icu-config --ldflags gave -L/mingw64/lib -licuin -licuuc -licudt. – spot Aug 31 '21 at 04:29
1

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.

Benoit
  • 11
  • 1