Julius Haertl wrote:
> Hello ,
>
> I'm trying to build OpenSceneGraph for Android and getting started with the
> osgViewer example application. After getting around the first errors, I'm
> quite
> stuck with the following while building with ndk-build.
> ndk-build keeps complaining about missing reference of rand and stat64.
>
I realise you're no longer using OpenSceneGraph for Android natively, but I had
this problem yesterday and came across your post, then figured out what the
problem was and how to fix it, so thought I would post it in case anyone else
is having the same trouble.
This is a long explanation, so if you just want to know the fix, scroll down to
"FIX IS HERE"
The problem is a combination of newer Android NDK platforms not supporting
these functions properly (I don't exactly know what changed or why), and
OpenSceneGraph giving an APP_PLATFORM which is no longer accepted by newer
Android NDK platforms.
The newer Android NDK platforms don't support the rand and stat64 functions, so
we want to compile the OpenSceneGraph libraries on a lower version platform,
such as 8 or 9. In the official documentation we're told that we can set the
version platform using the CMAKE commands:
Code:
-DANDROID_ABI "armeabi armeabi-v7a"
-DANDROID_PLATFORM=8
First of all, that first line should actually be
Code:
-DANDROID_ABI="armeabi armeabi-v7a"
Secondly, ANDROID_PLATFORM gets passed into
PlatformSpecifics/Android/Application.mk.master.in in the following line:
Code:
APP_PLATFORM := ${ANDROID_PLATFORM}
Meaning passing "8" in as ANDROID_PLATFORM will give us "APP_PLATFORM:=8".
However APP_PLATFORM is always denoted "android-X", where X is the platform
number ("APP_PLATFORM:=x" used to also work on earlier versions of the NDK, but
not new ones).
(As an aside, not setting ANDROID_PLATFORM will default it to the value "5",
which means we end up with APP_PLATFORM:=5, and the exact same problem).
If we try and build with an invalid APP_PLATFORM, we get the follow message
from the NDK:
Code:
2> Android NDK: Application local targets unknown platform '8'
2> Android NDK: Switching to android-21
Where "android-21" will be the highest supported android platform, which is one
which doesn't support the functions rand, stat64, etc.
"FIX IS HERE"
Basically the solution to this is to alter your Application.mk file so that it
has a valid APP_PLATFORM. This can be done one of two ways:
1) If you've already used CMAKE to create the project files, go into that
directory and modify the Application.mk file so that the APP_PLATFORM line
reads "APP_PLATFORM:=android-8" or "APP_PLATFORM:=android-9"
2) If you haven't already used CMAKE, or you want to fix the problem properly,
go into OSG_ROOT/PlatformSpecifics/Android/Application.mk.master.in and change
the line:
Code:
APP_PLATFORM := ${ANDROID_PLATFORM}
to
Code:
APP_PLATFORM := android-${ANDROID_PLATFORM}
and then use CMAKE to recreate your project and rebuild.
Hopefully this is helpful to someone.
Cheers,
Adrian
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=62012#62012
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org