[Android] CMake uses Bionic libz by default=> link error

Discussion of issues specific to mobile platforms such as iOS, Android, Symbian and Meego.
Post Reply
Posts: 40
Joined: Wed Jun 12, 2013 5:38 pm
Location: Finland
x 2

[Android] CMake uses Bionic libz by default=> link error

Post by Spekoda »

Hei guys!

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:

Code: Select all

ib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: C
ead.o): in function non-virtual thunk to boost::exception_detail::error_info_inj
16exception_detail19error_info_injectorINS_15condition_errorEED1Ev+0x4): warning
: relocation refers to discarded section
Install        : libOgreJNI.so => libs/armeabi-v7a/libOgreJNI.so

This is what the book 'Pro Android C++ with the NDK' says about bionic (page 156):

"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.

Post Reply