I noticed CMake finds the Bionic header and lib for libz by default from %ANDROID_NDK%\platforms\android-9\arch-arm\usr\ include and lib, rather than from %OGRE_SOURCE%\AndroidDependencies\ include and lib directories. This seems to cause a linker warning in nmake when building OgreJNI or SampleBrowser with boost threading. (Btw. Boost needs to be added manually to Android.mk files). Yet the build succeeds with nmake but not with eclipse. Eclipse treats them as errors.
When running ndk-build all from visual studio 2012 command prompt in \OgreJNI, I get a lot of warnings such as the following:
This is what the book 'Pro Android C++ with the NDK' says about bionic (page 156):
Code: Select all
C:/droid/ndk8e_32/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../l ib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: C :/ogre/sorsa/AndroidDependencies/include/lib/libboost_thread-gcc-mt-s-1_53.a(thr ead.o): in function non-virtual thunk to boost::exception_detail::error_info_inj ector<boost::condition_error>::~error_info_injector():thread.cpp(.text._ZN5boost 16exception_detail19error_info_injectorINS_15condition_errorEED1Ev+0x4): warning : relocation refers to discarded section Install : libOgreJNI.so => libs/armeabi-v7a/libOgreJNI.so c:\Ogre\sorsa\droidbld4_7\OgreJNI>
"Even though it is a C standard library, Bionic is not in any way binary-compatible with other C
libraries. Object files and static libraries that are produced against other C libraries should not be
dynamically linked with Bionic. Doing so will usually result in the inability to link or execute your
native applications properly.
Besides that, any application that is generated by statically linking with other C libraries and not
mixed with Bionic can run on the Android platform without any issues, unless it is dynamically
loading any other system library during runtime."
As the build succeeds I wonder if it will cause unexpected problems/crashes at runtime, the sample browser seems to run fine on my android device?
The simple fix seems to be changing the filename of libzlib.a to libz.a in \AndroidDependencies\lib\armeabi(-v7a)\ or in cmake if building dependencies yourself.