I propose Android developpers using STLport to share their experience
(compiling issues, reliability of the Android version - has somebody
already run the unit tests?).
To begin, STLport has to be used as a shared library (see global
constructors problems:
http://www.google.com/url?sa=D&q=https://sourceforge.net/tracker/%3Ffunc%3Ddetail%26aid%3D2972060%26group_id%3D146814%26atid%3D766244&usg=AFQjCNGvWx3mhlu-YmxJBiSXBU1zlibtgA
)
However, I have only managed to use a static version.
### Access to shared libraries
On Android, there seem to be no LD_LIBRARY_PATH yet (see
http://groups.google.com/group/android-ndk/browse_thread/thread/e0c175ed665f8c4d/4147e395ac3004af?lnk=gst&q=LD_LIBRARY_PATH+#4147e395ac3004af
).
So how to make an Android package including a Jni shared library which
uses an additional shared library like STLport? Is there no way to use
a shared library installed in an Android package directory at all?
I checked that if we put the additional library also in $
{android_project}/libs/arm-libs, it gets installed to the device
indeed, but it's not found at runtime because it's not in /system/
lib...
For testing, we can copy the .so to /system/lib using:
adb root
adb shell mount -w -o remount /dev/block/mtdblock3 /system
### Linking error
At runtime, I get:
link_image[1638]: 474 could not load needed library 'libstlport.so'
for './stl_unit_test' (reloc_library[1186]: 474 In 'libstlport.so',
shndx=0 && value=0x00000001. We do not handle this yet)CANNOT LINK
EXECUTABLE
(The linker does find the shared library - otherwise, we get only the
first part of the message).
This looks like an unimplemented feature in Android dynamic loader
(Bionic, line 1186):
http://gitorious.org/0xdroid/bionic/blobs/fde8642fc43bdd224e43e5ee9583a49a758fb03c/linker/linker.c
if ((s->st_shndx == SHN_UNDEF) && (s->st_value != 0)) {
This seems to be an undefined symbols with a non-null address,
according to http://docsrv.sco.com/SDK_cprog/OF_SymTable.html, what
does this case mean? (a random though: perhaps a prelink address? -
I've no specific knowledge about dynamic linking).
What would be possible linking options for STLport which would avoid
using this unimplemented linking feature?
Thanks!
Emmanuel
This looks like an unimplemented feature in Android dynamic loader
(Bionic, line 1186):
http://gitorious.org/0xdroid/bionic/blobs/fde8642fc43bdd224e43e5ee9583a49a758fb03c/linker/linker.c
if ((s->st_shndx == SHN_UNDEF) && (s->st_value != 0)) {
This seems to be an undefined symbols with a non-null address,
according to http://docsrv.sco.com/SDK_cprog/OF_SymTable.html, what
does this case mean? (a random though: perhaps a prelink address? -
I've no specific knowledge about dynamic linking).
What would be possible linking options for STLport which would avoid
using this unimplemented linking feature?
Thanks!
Emmanuel
--
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.
** Here is the Android.mk for the library (in the source directory):
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
ifdef STLG
LOCAL_MODULE := stlport_stlg
else
LOCAL_MODULE := stlport
endif
LOCAL_SRC_FILES := \
strstream.cpp messages.cpp iostream.cpp ctype.cpp dll_main.cpp
complex_trig.cpp locale_catalog.cpp complex_io.cpp allocators.cpp
string.cpp ostream.cpp locale_impl.cpp libstlport.so locale.cpp
istream.cpp time_facets.cpp fstream.cpp bitset.cpp codecvt.cpp
stdio_streambuf.cpp complex.cpp ios.cpp sstream.cpp num_put.cpp
num_put_float.cpp cxa.c facets_byname.cpp numpunct.cpp monetary.cpp
num_get_float.cpp num_get.cpp c_locale.c collate.cpp
#locale_impl.cpp ios.cpp monetary.cpp num_put_float.cpp numpunct.cpp
cxa.c time_facets.cpp wince_env.cpp warning_disable.h dll_main.cpp
collate.cpp num_get_float.cpp Application.mk istream.cpp _stdio_file.h
stdio_streambuf.h wince_multibyte.cpp num_get.cpp acquire_release.h
fstream.cpp stlport.rc wince_file.cpp c_locale.c strstream.cpp
complex.cpp message_facets.h wince_string.cpp sstream.cpp ostream.cpp
aligned_buffer.h ctype.cpp c_locale.h locale_impl.h iostream.cpp
codecvt.cpp messages.cpp Android.mk string.cpp facets_byname.cpp
bitset.cpp wince_time.cpp locale.cpp lock_free_slist.h
stdio_streambuf.cpp complex_io.cpp sparc_atomic.s allocators.cpp
details/fstream_stdio.cpp details/fstream_unistd.cpp details/
fstream_win32io.cpp locale_catalog.cpp complex_trig.cpp num_put.cpp
stlport_prefix.h
LOCAL_CFLAGS = -Iapps/$(LOCAL_MODULE)/include \
-mandroid \
-DTARGET_OS=android \
--sysroot=build/platforms/android-5/arch-arm
ifeq ($(LOCAL_MODULE),stlport_stlg)
LOCAL_CFLAGS += -D_STLP_DEBUG
endif
include $(BUILD_SHARED_LIBRARY)
** and the Application.mk:
APP_PROJECT_PATH := $(call my-dir)
APP_MODULES := stlport
#STLG := 1
APP_BUILD_SCRIPT := $(APP_PROJECT_PATH)/Android.mk
#APP_OPTIM:=debug
APP_OPTIM:=release
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
ifdef STLG
LOCAL_MODULE := stl_unit_test_stlg
else
LOCAL_MODULE := stl_unit_test
endif
#1.6
#LOCAL_SRC_FILES := \
/opt/android-ndk-1.6_r1/build/prebuilt/linux-x86/arm-eabi-4.2.1/bin/../
lib/gcc/arm-eabi/4.2.1/android/crti.o /opt/android-ndk-1.6_r1/build/
prebuilt/linux-x86/arm-eabi-4.2.1/bin/../lib/gcc/arm-eabi/4.2.1/
android/crtbegin.o /opt/android-ndk/build/platforms/android-4/arch-
arm//usr/lib/crtbegin_dynamic.o \
/opt/android-ndk-1.6_r1/build/prebuilt/linux-x86/arm-eabi-4.2.1/
bin/../lib/gcc/arm-eabi/4.2.1/android/crtend.o /opt/android-ndk-1.6_r1/
build/prebuilt/linux-x86/arm-eabi-4.2.1/bin/../lib/gcc/arm-eabi/4.2.1/
android/crtn.o
#2
LOCAL_SRC_FILES := \
/opt/android-ndk/build/prebuilt/linux-x86/arm-eabi-4.4.0/lib/gcc/arm-
eabi/4.4.0/android/crti.o /opt/android-ndk/build/prebuilt/linux-x86/
arm-eabi-4.4.0/lib/gcc/arm-eabi/4.4.0/android/crtbegin.o /opt/android-
ndk/build/platforms/android-5/arch-arm//usr/lib/crtbegin_dynamic.o \
/opt/android-ndk/build/prebuilt/linux-x86/arm-eabi-4.4.0/lib/gcc/arm-
eabi/4.4.0/android/crtend.o /opt/android-ndk/build/prebuilt/linux-x86/
arm-eabi-4.4.0/lib/gcc/arm-eabi/4.4.0/android/crtn.o
LOCAL_SRC_FILES+= cppunit/test_main.cpp accum_test.cpp adj_test.cpp
advance_test.cpp alg_test.cpp algorithm_header_test.cpp
allocator_test.cpp bcompos_test.cpp bind_test.cpp binsert_test.cpp
bitset_test.cpp bitset_header_test.cpp bnegate_test.cpp
boost_check.cpp bound_test.cpp bsearch_test.cpp bvector_test.cpp
cassert_header_test.cpp cctype_header_test.cpp cerrno_header_test.cpp
cfloat_header_test.cpp ciso646_header_test.cpp climits_header_test.cpp
clocale_header_test.cpp cmath_test.cpp cmath_header_test.cpp
codecvt_test.cpp collate_facets_test.cpp complex_header_test.cpp
config_test.cpp copy_test.cpp count_test.cpp csetjmp_header_test.cpp
setjmp_header_test2.cpp csignal_header_test.cpp
cstdarg_header_test.cpp cstddef_header_test.cpp cstdio_header_test.cpp
cstdlib_header_test.cpp cstring_test.cpp cstring_header_test.cpp
ctime_header_test.cpp ctype_facets_test.cpp cwchar_header_test.cpp
cwctype_header_test.cpp deque_test.cpp deque_header_test.cpp
divides_test.cpp equal_test.cpp exception_test.cpp
exception_header_test.cpp epilog_test.cpp fill_test.cpp find_test.cpp
finsert_test.cpp foreach_test.cpp fstream_test.cpp
fstream_header_test.cpp func_test.cpp functional_header_test.cpp
generator_test.cpp greater_test.cpp hash_test.cpp heap_test.cpp
includes_test.cpp innerprod_test.cpp inplace_test.cpp insert_test.cpp
ioiter_test.cpp iomanip_header_test.cpp ios_header_test.cpp
iosfwd_header_test.cpp iostream_header_test.cpp iostream_test.cpp
iota_test.cpp istmit_test.cpp istream_header_test.cpp iter_test.cpp
iterator_header_test.cpp less_test.cpp lexcmp_test.cpp limits_test.cpp
limits_header_test.cpp list_test.cpp list_header_test.cpp
locale_test.cpp locale_header_test.cpp logic_test.cpp macro_checks.cpp
map_test.cpp map_header_test.cpp max_test.cpp memory_header_test.cpp
memory_test.cpp merge_test.cpp messages_facets_test.cpp
mfunptr_test.cpp min_test.cpp mismatch_test.cpp modulus_test.cpp
money_facets_test.cpp multiset_test.cpp mvctor_test.cpp
mvctor_declaration_test.cpp mvctor_traits_test.cpp neq_test.cpp
new_header_test.cpp nthelm_test.cpp num_facets_test.cpp
num_put_get_test.cpp numeric_header_test.cpp ostmit_test.cpp
ostream_header_test.cpp pair_test.cpp partial_test.cpp
partition_test.cpp perm_test.cpp plusminus_test.cpp ptr2_test.cpp
ptrspec_test.cpp queue_test.cpp queue_header_test.cpp
rawriter_test.cpp reference_wrapper_test.cpp resolve_name.cpp
reviter_test.cpp rm_cp_test.cpp rndshf_test.cpp rope_test.cpp
rotate_test.cpp search_test.cpp set_test.cpp set_header_test.cpp
setdiff_test.cpp setinter_test.cpp setunion_test.cpp
shared_ptr_test.cpp slist_test.cpp sort_test.cpp sstream_test.cpp
sstream_header_test.cpp stack_test.cpp stack_header_test.cpp
stdexcept_header_test.cpp stldbg_include.cpp string_test.cpp
strstream_buffer_read_test.cpp strstream_header_test.cpp swap_test.cpp
times_test.cpp transform_test.cpp type_traits_test.cpp
typeinfo_header_test.cpp unary_test.cpp uninitialized_test.cpp
unique_test.cpp unordered_test.cpp utility_header_test.cpp
valarray_test.cpp valarray_header_test.cpp vector_test.cpp
vector_header_test.cpp test_errno.cpp time_facets_test.cpp
assert_header_test.c ctype_header_test.c c_limits_header_test.c
c_locale_header_test.c errno_header_test.c float_header_test.c
iso646_header_test.c math_header_test.c setjmp_header_test.c
signal_header_test.c stdarg_header_test.c stddef_header_test.c
stdio_header_test.c stdlib_header_test.c string_header_test.c
time_header_test.c wchar_header_test.c wctype_header_test.c
LOCAL_CFLAGS += \
-DSTLPORT # XXX because of rope_test.cpp # ou #include features.h (/
opt/android-ndk-1.6_r1/dgil/dgil_specific/android/stlport-git/include-
stlport/stl/config/features.h:567:1:)
#stl
STLPORT_BASE := $(ANDROID_NDK_ROOT)/dgil/dgil_specific/android/stlport-
git
LOCAL_CFLAGS += -I$(STLPORT_BASE)/include-stlport \
-D__NEW__ \
-D__SGI_STL_INTERNAL_PAIR_H \
-DANDROID \
-DOS_ANDROID \
-D_STLP_NO_CWCHAR
# wchar: already in android
# for stlport-git 5.2 20100305
LOCAL_CFLAGS += -D__ANDROID__ \
-isystem build/platforms/android-5/arch-arm/usr/include
LOCAL_LDLIBS += -L$(STLPORT_BASE)/lib-arm-ndk
ifeq ($(LOCAL_MODULE),stl_unit_test_stlg)
LOCAL_LDLIBS += -lstlport_stlg
else
LOCAL_LDLIBS += -lstlport
endif
include $(BUILD_EXECUTABLE)
*** Application.mk
APP_PROJECT_PATH := $(call my-dir)
APP_MODULES := stl_unit_test
While trying to reproduce your steps, I'm hitting this compiler error
while compiling dll_main.cpp with NDK1.6r3. Do you have any tips on
what's going on? It seems that stl_pair.h in "build/platforms/
android-3/arch-arm/usr/include" is causing error. If I remove the
first include path then dll_main.cpp builds fine, but it's auto
inserted by the build system.
Compile++ thumb: stlport <= apps/stlport/src/dll_main.cpp
build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/arm-eabi-g++ -Ibuild/
platforms/android-3/arch-arm/usr/include -fpic -mthumb-interwork -
ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -
D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -
D__ARM_ARCH_5TE__ -march=armv5te -mtune=xscale -msoft-float -fno-
exceptions -fno-rtti -mthumb -Os -fomit-frame-pointer -fno-strict-
aliasing -finline-limit=64 -Iapps/stlport/src -DANDROID -Iapps/
stlport/include -mandroid -DTARGET_OS=android --sysroot=build/
platforms/android-5/arch-arm -O2 -DNDEBUG -g -c -MMD -MP -MF out/
apps/stlport/armeabi/objs/stlport/dll_main.o.d.tmp apps/stlport/src/
dll_main.cpp -o out/apps/stlport/armeabi/objs/stlport/dll_main.o
In file included from apps/stlport/include/stl/_algobase.h:50,
from apps/stlport/include/stl/_alloc.h:43,
from apps/stlport/include/memory:29,
from apps/stlport/src/dll_main.cpp:41:
apps/stlport/include/stl/_pair.h:47: error: redefinition of 'struct
std::pair<_T1, _T2>'
build/platforms/android-3/arch-arm/usr/include/stl_pair.h:64: error:
previous definition of 'struct std::pair<_T1, _T2>'
apps/stlport/include/stl/_pair.h:77: error: redefinition of
'template<class _T1, class _T2> bool std::operator==(const
std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)'
> opt/android-ndk-1.6_r1/dgil/dgil_specific/android/stlport-git/include-stlport/stl/config/features.h:567:1:)
>
> #stl
> STLPORT_BASE := $(ANDROID_NDK_ROOT)/dgil/dgil_specific/android/stlport-
> git
> LOCAL_CFLAGS += -I$(STLPORT_BASE)/include-stlport\
> -D__NEW__ \
> -D__SGI_STL_INTERNAL_PAIR_H \
> -DANDROID \
> -DOS_ANDROID \
> -D_STLP_NO_CWCHAR
> # wchar: already in android
> # forstlport-git 5.2 20100305
I had to add this line because the Ndk uses this directory with -I,
and then the C++ Android headers get precedence over stl headers,
which results in compilation errors. With -isystem, it looses the
precedence. (There should be a better way to do that I guess. At least
use a Ndk variable to get the directory).
Emmanuel
static {
System.loadLibrary ( "stlport" );
System.loadLibrary ( ... ); // as usual the application Jni
lib
}
Emmanuel
I read the arguments rendered by the Google upstream gods and then took
a look at the STL code generation.
I agreed. I then hand wrote the containers and other STL objects that my
portable hand held application uses.
I had a whole lot a fun, like who has written double linked list object
code since the 1980's? Or strings even?
The way I figure it is, do you want to eat at McDonald's or do you want
to cook your own slow food?
- one gray beard opinion
LOCAL_CFLAGS += -D__ANDROID__ \
-isystem $(SYSROOT)/usr/include \
1) an error for each of the .c sources, e.g.
"make: *** No rule to make target `/cxa.c', needed by `out/apps/
stlport/armeabi/objs/stlport/cxa.o'. Stop"
it does not like the presence of them together with the others, .cpp
ones.
2) even if i remove .c files form LOCAL_SRC_FILES, and manage to build
a shared library, it fails to link against allocate/deallocate for a
basic test using stl container.
".../stltest.o: In function `std::__node_alloc::allocate(unsigned
int&)':
.../stlport/stl/_alloc.h:158: undefined reference to
`std::__node_alloc::_M_allocate(unsigned int&)'
"
It seems like symbols are simply not exported!?!
that's all i've got
"build/prebuilt/darwin-x86/arm-eabi-4.4.0/bin/arm-eabi-nm out/apps/
stlport/armeabi/libstlport.so
00001228 a _DYNAMIC
000012a8 a _GLOBAL_OFFSET_TABLE_
000012b4 A __bss_end__
000012b4 A __bss_start
000012b4 A __bss_start__
000012b4 D __data_start
000012b4 A __end__
00000227 A __exidx_end
00000227 A __exidx_start
000012b4 A _bss_end__
000012b4 A _edata
000012b4 A _end
00080000 D _stack
- copy Android.mk and Application.mk to $STLPORT_DIR/sltport/src
- ln -s $STLPORT_DIR/sltport/src $NDK_DIR/apps/stlport
- make -C $NDK_DIR APP=stlport
You can get attached files here:
https://sourceforge.net/tracker/index.php?func=detail&aid=2972060&group_id=146814&atid=766244
1) $STLPORT_DIR/sltport/src does not exist, you've probably meant
$STLPORT_DIR/src
2) you have "-Iapps/$(LOCAL_MODULE)/include" in Android.mk, there is
no such path in the dictribution, which needs to be linked to
$STLPORT_DIR/sltport by the looks of it
3) going further some genius put #include_next instead of #include,
never used that before, it seem it does not find include from "-I/
path"; after replacing each 'include_next' with 'include' seems to
create a circular includes...
argh!!! enough time wasted!!
i think i might try Dimitri's toolkit. If that one does not work it
might be easier to write containers myself, like Gerard suggested,
instead of playing about trying to fingure out how every possible
compiler in the world and makefile hierarchy works!
> You can get attached files here:https://sourceforge.net/tracker/index.php?func=detail&aid=2972060&gro...
Hope that helps
1) 2) You're right, I correct:
- copy Android.mk and Application.mk to $STLPORT_DIR/src
- ln -s $STLPORT_DIR/src $NDK_DIR/apps/stlport
- ln -s $STLPORT_DIR/src/include $STLPORT_DIR/src
- make -C $NDK_DIR APP=stlport
> 3) going further some genius put #include_next instead of #include,
> never used that before, it seem it does not find include from "-I/
> path"; after replacing each 'include_next' with 'include' seems to
> create a circular includes...
Indeed, STLport replaces some C++ headers, but uses also the original
headers, so the management of include paths is delicate... The fix
from the 8th of April (and 1rst) message of this discussion should
deal with that (no need to modify source code).
You can check that compiling with make V=1 -C ..., you get the same
version of include path for both the -I and -isystem options (like
build/platforms/android-3/arch-arm/usr/include ).