android - Libogg compiled with standalone toolchain (generated by NDK script) tries to load itself from incorrect file - libogg.so.0 instead of libogg.so -
i'm trying add libogg android ndk project.
i'm using project template comes sdl library.
i'm on windows, following scripts executed under msys, linux terminal emulator.
first, generated standalone toolchain.
android-ndk/build/tools/make-standalone-toolchain.sh --platform=android-12 --system=windows-x86_64 --toolchain=arm-linux-androideabi-4.9 --install-dir=y:/gcc_android_androideabi-4.9_api12/
then built library.
make clean configure cc="/y/gcc_android_androideabi-4.9_api12/bin/arm-linux-androideabi-gcc" libs="-lgnustl_shared" cflags="-mthumb" --host=arm-linux-androideabi make
then copied resulting libogg.so
project folder , added following jni/src/android.mk
:
... include $(clear_vars) local_module := ogg-prebuilt local_src_files := ../../prebuilt-libs/$(target_arch_abi)/libogg.so include $(prebuilt_shared_library) ... local_shared_libraries := ... ogg-prebuilt ... ...
similar code works fine libraries use.
ndk-build
finds libraries , adds them .apk
.
the problem arises when call system.loadlibrary("ogg");
@ runtime. dynamic linker gives me error message saying like
can't find library "libogg.so.0".
i'm sure library loading code ok because works other libraries have.
error dynamic linker interesting because make
not generated single libogg.so
. generated 3 same files different names: libogg.so
, libogg.so.0
, libogg.so.0.8.2
.
i tried replace libogg.so
libogg.so.0
, adjusted android.mk
properly, ndk build script yelled @ me, saying prebuilt shared libraries must have .so
extension. tried copy libogg.so.0
libs/
folder, ndk build script ignored when building .apk
.
then opened libogg.so
in hex editor , searched libogg
. found 1 occurence: libogg.so.0[nul]
. replaced .0
2 [nul]
s, became libogg.so[nul][nul][nul]
, library loads perfectly.
i can reproduce error toolchains use: arm-linux-androideabi-gcc-4.9
, i686-linux-android-gcc-4.9
, mipsel-linux-android-gcc-4.9
. generated using similar scripts.
the error persists if rename libogg.so.0
or libogg.so.0.8.2
libogg.so
, use instead of original one. said, 3 files have same content.
while can make sed
script automatically fix library name in .so
files when necessary, wonder if there better solution problem.
maybe have add flags configure
?
my less hacky fix remove version information build system of libogg.
in directory have libogg source code, open file src/makefile.am
, change line:
libogg_la_ldflags = -no-undefined -version-info @lib_current@:@lib_revision@:@lib_age@
to
libogg_la_ldflags = -avoid-version
if don't have automake installed can change generated makefile after running ./configure
. find libogg_la_ldflags
, make similar change 1 detailed above. on linux sed one-liner job:
sed -i 's/^libogg_la_ldflags.*/libogg_la_ldflags = -avoid-version/g' src/makefile
Comments
Post a Comment