7

For last couple of days I've been trying to figure out how to implement ICU library for Android support. I stuck on very begining, trying to compile ICU sources with NDK. I got them from here: https://android.googlesource.com/platform/external/icu/

I put it in my jni location and added in my Android.mk file this line:

include $(call all-subdir-makefiles)

and added to local flags:

-DSQLITE_ENABLE_ICU

I'm getting a lot of errors trying to build it (on Windows machine). Here is my output:

c:/ndk/build/core/build-binary.mk:457: warning: overriding commands for target `
    "----my android project location----"//obj/local/armeabi/objs/icui1
    8n/smpdtfst.o'
    c:/ndk/build/core/build-binary.mk:457: warning: ignoring old commands for target
     `"----my android project location----"//obj/local/armeabi/objs/icu
    i18n/smpdtfst.o'
    c:/ndk/build/core/build-binary.mk:457: warning: overriding commands for target `
    "----my android project location----"//obj/local/armeabi/objs/icui1
    8n_static/smpdtfst.o'
    c:/ndk/build/core/build-binary.mk:457: warning: ignoring old commands for         target
 `"----my android project location----"//obj/local/armeabi/objs/icu
    i18n_static/smpdtfst.o'
    [armeabi] Compile thumb  : icui18n <= decContext.c
    [armeabi] Compile thumb  : icui18n <= ucln_in.c
    [armeabi] Compile thumb  : icui18n <= ulocdata.c
    [armeabi] Compile++ thumb: icui18n <= indiancal.cpp
    [armeabi] Compile++ thumb: icui18n <= dtptngen.cpp
    [armeabi] Compile thumb  : icui18n <= decNumber.c
    [armeabi] Compile thumb  : icui18n <= utmscale.c
    [armeabi] Compile++ thumb: icui18n <= dtrule.cpp
    In file included from "----my android project location----"//jni/ic
    u/icu4c/source/i18n/../common/unicode/unistr.h:31:0,
                 from "----my android project location----"//jni/ic
    u/icu4c/source/i18n/../common/unicode/locid.h:34,
                 from "----my android project location----"//jni/ic
    u/icu4c/source/i18n/unicode/calendar.h:37,
                 from "----my android project location----"//jni/ic
u/icu4c/source/i18n/indiancal.h:18,
                 from "----my android project location----"//jni/ic
u/icu4c/source/i18n/indiancal.cpp:10:
"----my android project location----"//jni/icu/icu4c/source/i18n/..
/common/unicode/std_string.h:33:18: fatal error: string: No such file or directo
ry
 #include <string>
                  ^
compilation terminated.
make.exe: *** ["----my android project location----"//obj/local/arm
eabi/objs/icui18n/indiancal.o] Error 1
make.exe: *** Waiting for unfinished jobs....
In file included from "----my android project location----"//jni/ic
u/icu4c/source/i18n/../common/unicode/unistr.h:31:0,
                 from "----my android project location----"//jni/ic
u/icu4c/source/i18n/../common/unicode/strenum.h:14,
                 from "----my android project location----"//jni/ic
u/icu4c/source/i18n/../common/unicode/uenum.h:24,
                 from "----my android project location----"//jni/ic
u/icu4c/source/i18n/unicode/ucal.h:12,
                 from "----my android project location----"//jni/ic
u/icu4c/source/i18n/unicode/udat.h:16,
                 from "----my android project location----"//jni/ic
u/icu4c/source/i18n/unicode/datefmt.h:26,
                 from "----my android project location----"//jni/ic
u/icu4c/source/i18n/dtptngen.cpp:15:
"----my android project location----"//jni/icu/icu4c/source/i18n/..
/common/unicode/std_string.h:33:18: fatal error: string: No such file or directo
ry
 #include <string>
                  ^
compilation terminated.
make.exe: *** ["----my android project location----"//obj/local/arm
eabi/objs/icui18n/dtptngen.o] Error 1
"----my android project location----"//jni/icu/icu4c/source/i18n/dt
rule.cpp: In member function 'UBool icu_54::DateTimeRule::operator==(const icu_5
4::DateTimeRule&) const':
"----my android project location----"//jni/icu/icu4c/source/i18n/dt
rule.cpp:85:22: error: cannot use typeid with -fno-rtti
             (typeid(*this) == typeid(that) &&
                      ^
"----my android project location----"//jni/icu/icu4c/source/i18n/dt
rule.cpp:85:38: error: cannot use typeid with -fno-rtti
             (typeid(*this) == typeid(that) &&
                                      ^
make.exe: *** ["----my android project location----"//obj/local/arm
eabi/objs/icui18n/dtrule.o] Error 1

and here is my main Android.mk file located in jni directory:

LOCAL_PATH:= $(call my-dir)
include $(call all-subdir-makefiles)
include $(CLEAR_VARS)

LOCAL_MODULE:= sqlitenative

LOCAL_SRC_FILES := sqlite3.c sqlite3_native.cpp

# NOTE the following flags,
#   SQLITE_TEMP_STORE=3 causes all TEMP files to go into RAM. and thats the      behavior we want
#   SQLITE_ENABLE_FTS3   enables usage of FTS3 - NOT FTS1 or 2.
#   SQLITE_DEFAULT_AUTOVACUUM=1  causes the databases to be subject to auto-    vacuum
#   SQLITE_HAS_CODEC enables crypto support for database
LOCAL_CFLAGS += -DHAVE_USLEEP=1 \
        -DSQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576 \
        -DSQLITE_THREADSAFE=1 \
        -DNDEBUG=1 \
        -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1 \
        -DSQLITE_DEFAULT_AUTOVACUUM=1 \
        -DSQLITE_TEMP_STORE=3 \
        -DSQLITE_ENABLE_FTS3 \
        -DSQLITE_ENABLE_FTS3_PARENTHESIS \
        -DSQLITE_ENABLE_COLUMN_METADATA \
        -DSQLITE_ENABLE_ICU \
        -DHAVE_STRCHRNUL=0

LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog -lc
LOCAL_C_INCLUDES += $(call include-path-for, system-core)/cutils

LOCAL_SHARED_LIBRARIES += libicuuc \
        libicui18n \
        libutils

LOCAL_SHARED_LIBRARIES += libicuuc-host libicui18n-host
LOCAL_STATIC_LIBRARIES := liblog libutils libcutils

include $(BUILD_SHARED_LIBRARY)
include $(BUILD_HOST_SHARED_LIBRARY)
elhm
  • 145
  • 1
  • 10
  • The source tree from [googlesource](https://android.googlesource.com/platform/external/icu/) is to be built by [`lunch`](https://source.android.com/source/building-running.html#build-the-code) command. This environment is similar, but significantly different from NDK. You must rewrite the `Android.mk` files. – Alex Cohn Mar 11 '15 at 15:25
  • But is it possible to build it on Windows machine? – elhm Mar 12 '15 at 09:42
  • 2
    I would not encourage you to spend your time on this, if you are not proficient with cygwin, make, and ndk. It is much easier to compile the library under Ubuntu, in a virtual box. Actually, you don't see a strong reason in building this library on your own: it is already part (albeit unofficial) of any Android installation. You can simply assume that `libicui18n.so` and `libicuuc.so` are present in `/system/lib` and use them! – Alex Cohn Mar 12 '15 at 11:36
  • You can build ICU for Android using the NDK's standalone toolchain, configure && make. You'll have to pass some flags that you likely get away with not passing for a host build, but it works. – NuSkooler Jun 09 '15 at 15:24
  • Minor update: Please do not link against "unofficial" Android system libraries. They can -- and will -- change at any time. Additionally, Google will begin marking symbols private with Android N+. See http://android-developers.blogspot.com/2016/06/improving-stability-with-private-cc.html – NuSkooler Jun 24 '16 at 16:05
  • Possible duplicate of [Include ICU in Android NDK Project](http://stackoverflow.com/questions/18235428/include-icu-in-android-ndk-project) – Paul Sweatte Apr 25 '17 at 16:23

0 Answers0