Building icu on a mac

535 views
Skip to first unread message

marcu...@gmx.net

unread,
Oct 5, 2011, 3:40:58 AM10/5/11
to android-ndk
Hello,

I have a project which I want to convert from iphone to android.
IPhones does not allow a link to icu libaries because of some hidden
api calls, therefore I have included .h and .c files of icu which I
need.

When I build the .c files now it tries to include some mac headers
which are only available in the iphone section but not in the android
build env.
umutex.c
#include <AvailabilityMacros.h>
#include <libkern/OSAtomic.h>

Can it be build in e.g. umutex.c with such includes on a mac or do I
need linux to build it?

Is it save to drop the .c files and have a link to libicuuc.so?
Can I get the libicuuc.so from my device and link it?

regards,
Marcus

David Turner

unread,
Oct 6, 2011, 10:26:43 AM10/6/11
to andro...@googlegroups.com
On Wed, Oct 5, 2011 at 12:40 AM, marcu...@gmx.net <marcu...@gmx.net> wrote:
Hello,

I have a project which I want to convert from iphone to android.
IPhones does not allow a link to icu libaries because of some hidden
api calls, therefore I have included .h and .c files of icu which I
need.

When I build the .c files now it tries to include some mac headers
which are only available in the iphone section but not in the android
build env.
umutex.c
#include <AvailabilityMacros.h>
#include <libkern/OSAtomic.h>

Can it be build in e.g. umutex.c with such includes on a mac or do I
need linux to build it?


Generally speaking, iOS-specific headers, data types and libraries are simply not available on Android.
You will have to rewrite your code to use something else, or use an abstraction library, if such a thing exists (I honestly don't know)
 
Is it save to drop the .c files and have a link to libicuuc.so?
Can I get the libicuuc.so from my device and link it?

No, you can't. The version used by ICU in the system is not exposed by the system. Besides, it is sometimes customized by OEMs to only include the character/properties tables related to a subset of languages (this is mostly done to save space).

You will have to build and use your own version of ICU.
 
regards,
Marcus

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.


Gregory Ray

unread,
Oct 6, 2011, 5:53:39 PM10/6/11
to andro...@googlegroups.com
Should be able to build it from android open source externals.

marcu...@gmx.net

unread,
Oct 6, 2011, 7:30:20 PM10/6/11
to android-ndk
Thanks for your answers.

I got the sources of icu4c from android/external already a few hours
ago and it compiles but than I get

Install : libicudata-large.so => libs/armeabi/libicudata-
large.so
SharedLibrary : libicuuc.so
/tmp/myproject/obj/local/armeabi/objs/icuuc/udata.o: In function
`openCommonData':
/tmp/myproject/jni/icu4c/common/udata.c:828: undefined reference to
`icudt38_dat'

My Application.mk looks like
APP_ABI := armeabi armeabi-v7a
APP_MODULES := libicudata-large libicudata libicuuc libicui18n
myproject
APP_PLATFORM := android-8

My Android.mk is only
include $(call all-subdir-makefiles)


I have no clue what todo ... I think I have to change an Android.mk
from the orig. android source code but how?

I assume the problem is somewhere in the icu4c/stubdata/Android.mk
because there is LOCAL_GENERATED_SOURCES used which I cannot find in
any NDK documentation.

...
intermediates := $(call local-intermediates-dir)
icu_data_file := $(LOCAL_PATH)/icudt38l-large.dat

asm_file := $(intermediates)/icu_data_large.S
LOCAL_GENERATED_SOURCES += $(asm_file)
$(asm_file): PRIVATE_VAR_NAME := $(icu_var_name)
$(asm_file): $(icu_data_file) $(ICUDATA)
@echo icudata: $@
$(hide) mkdir -p $(dir $@)
$(hide) $(ICUDATA) $(PRIVATE_VAR_NAME) < $< > $@


If anyone has any idea how to build libicuuc as static or shared lib I
would really appreciated it.

regards,
Marcus.

On Oct 6, 11:53 pm, Gregory Ray <gr...@fezo.com> wrote:
> Should be able to build it from android open source externals.
>
>
>
>
>
>
>
> On Thu, Oct 6, 2011 at 7:26 AM, David Turner <di...@android.com> wrote:
>

Gregory Ray

unread,
Oct 6, 2011, 8:01:25 PM10/6/11
to andro...@googlegroups.com
Might want to check the readme.html, seems to be jam packed with documentation (not ndk specific). Please let me know if you solve this (and how it was solved).

marcu...@gmx.net

unread,
Oct 7, 2011, 7:41:03 AM10/7/11
to android-ndk
I red the readme.html but it did not help.

I use an older source of android to build but I still have some
problems.

What I figured out that when I call ./runConfigureICU MacOSX in the
icu4c directory
it tries to load header files which do not exist. Without calling it
works.

Because of my older android code I used this patch
http://git.tarot.com.tw/?p=android/platform/external/icu4c.git;a=commitdiff;h=d60a22e7a4de8de9c2f4f577b4b41df82002a3b8

where in the common/Android.mk is changed to
'-DICU_DATA_DIR="/system/usr/icu"'
specified.

That solved my "undefined reference to `icudt38_dat'" problem but I
dont know if it will work on the device. Because I use a newer icu
code than the android source I used seems I need to upgrade to a newer
android source because of some other "undefined reference".
I currently checkout the froyo code and try it again. Hope it works
there too.

regards,
Marcus

On Oct 7, 2:01 am, Gregory Ray <gr...@fezo.com> wrote:
> Might want to check the readme.html, seems to be jam packed with
> documentation (not ndk specific). Please let me know if you solve this (and
> how it was solved).
>

marcu...@gmx.net

unread,
Oct 7, 2011, 7:14:42 PM10/7/11
to android-ndk
I managed now to build my code
I use an stl_port (crystax) to build my code.

in my Android.mk I have
LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/../icu4c/common \
...

LOCAL_STATIC_LIBRARIES := libpng freetype zlib
LOCAL_SHARED_LIBRARIES := libicudata libicuuc libicui18n


but when I load it in the
System.loadLibrary("icuuc");
System.loadLibrary("icui18n");
System.loadLibrary("mypro");
It fails to load because of a missing reference. Has anyone an idea
what is missing.
Or do I need also to load something for the stl_port

10-08 00:53:20.848: DEBUG/dalvikvm(640): Trying to load lib /data/data/
com.marcus.mypro/lib/libicuuc.so 0x40514670
10-08 00:53:20.859: DEBUG/dalvikvm(640): Added shared lib /data/data/
com.marcus.mypro/lib/libicuuc.so 0x40514670
10-08 00:53:20.859: DEBUG/dalvikvm(640): No JNI_OnLoad found in /data/
data/com.marcus.mypro/lib/libicuuc.so 0x40514670, skipping init
10-08 00:53:20.867: DEBUG/dalvikvm(640): Trying to load lib /data/data/
com.marcus.mypro/lib/libicui18n.so 0x40514670
10-08 00:53:20.867: DEBUG/dalvikvm(640): Added shared lib /data/data/
com.marcus.mypro/lib/libicui18n.so 0x40514670
10-08 00:53:20.867: DEBUG/dalvikvm(640): No JNI_OnLoad found in /data/
data/com.marcus.mypro/lib/libicui18n.so 0x40514670, skipping init
10-08 00:53:20.877: DEBUG/dalvikvm(640): Trying to load lib /data/data/
com.marcus.mypro/lib/libulm_myproj.so 0x40514670
10-08 00:53:21.029: DEBUG/myproj(640): Cannot load lib: Cannot load
library: reloc_library[1311]: 33 cannot locate
'_ZN7icu_3_813UnicodeStringaSERKS0_'...
10-08 00:53:21.029: DEBUG/myproj(640): java.lang.UnsatisfiedLinkError:
Cannot load library: reloc_library[1311]: 33 cannot locate
'_ZN7icu_3_813UnicodeStringaSERKS0_'...
10-08 00:53:21.029: DEBUG/myproj(640): at
java.lang.Runtime.loadLibrary(Runtime.java:434)
10-08 00:53:21.029: DEBUG/myproj(640): at
java.lang.System.loadLibrary(System.java:554)
10-08 00:53:21.029: DEBUG/myproj(640): at
com.marcus.mypro.jni.NativeMap.<clinit>(NativeMap.java:23)
...

regards,
marcus


On Oct 7, 1:41 pm, "marcuseb...@gmx.net" <marcuseb...@gmx.net> wrote:
> I red the readme.html but it did not help.
>
> I use an older source of android to build but I still have some
> problems.
>
> What I figured out that when I call ./runConfigureICU MacOSX in the
> icu4c directory
> it tries to load header files which do not exist. Without calling it
> works.
>
> Because of my older android code I used this patchhttp://git.tarot.com.tw/?p=android/platform/external/icu4c.git;a=comm...
Reply all
Reply to author
Forward
0 new messages