Hi there, We have been attempting to build OSG for Android and thought it would be a good idea to share the steps we used to finally get it to work in Windows. This guide assumes you have Eclipse, the Android SDK and NDK installed and set up already. Whilst you may be used to using the NDK tools in Cygwin, we have only used CMD in this guide. The most important thing is to use the latest stable version of OSG (3.0.1) - we found that the svn trunk version just does not want to work. This is due to issues loading libraries as well as some problems with OSG its self.
As usual, your mileage may vary! Install make and MinGW ====================== - Download and install make from http://gnuwin32.sourceforge.net/downlinks/make.php; - Download and install MinGW from http://sourceforge.net/projects/mingw/files/latest/download?source=files. Don't forget to add the C++ compiler during the installation options; - Add the install directories to your PATH. Mine were C:\Program Files (x86)\GnuWin32\bin and C:\MinGW\bin. Setup a clean version of the OSG source ======================================= I used a clean version of the OSG source, because we are using a separate set of CMake commands. *** It is important to use the latest stable version (3.0.1), rather than the trunk, otherwise it will not work! *** To get a clean version: - Install tortoise SVN http://tortoisesvn.net/downloads.html ; - In C:\Local use SVN Checkout (a context menu option) http://www.openscenegraph.org/svn/osg/OpenSceneGraph/tags/OpenSceneGraph-3.0.1 Set the checkout-directory to be C:\Local\OpenSceneGraph-Android; - Make two new directories inside OpenSceneGraph-Android: build and osginstall; Now we build the OSG source. NOTE: if you have an NDK_PROJECT_PATH environment variable set you need to remove this now. - In CMD navigate to C:\Local\OpenSceneGraph-Android\build and run the following CMake command (-DJ=8 command tells make to use 8 cores - change this to match your system): cmake .. -G "MinGW Makefiles" -DOSG_BUILD_PLATFORM_ANDROID=ON -DDYNAMIC_OPENTHREADS=OFF -DDYNAMIC_OPENSCENEGRAPH=OFF -DOSG_GL_DISPLAYLISTS_AVAILABLE=OFF -DOSG_GL_MATRICES_AVAILABLE=ON -DOSG_GL_VERTEX_FUNCS_AVAILABLE=ON -DOSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE=ON -DOSG_GL_FIXED_FUNCTION_AVAILABLE=ON -DOSG_CPP_EXCEPTIONS_AVAILABLE=OFF -DOSG_GL1_AVAILABLE=OFF -DOSG_GL2_AVAILABLE=OFF -DOSG_GL3_AVAILABLE=OFF -DOSG_GLES1_AVAILABLE=ON -DOSG_GLES2_AVAILABLE=OFF -DJ=8 -DCMAKE_INSTALL_PREFIX=C:\Local\OpenSceneGraph-Android\osginstall - Run make - this takes a while! - Run make install which copies our include, lib and obj files into osginstall for us. Import osgAndroidExampleGLES1 to Eclipse and configure ====================================================== - Copy a version of the osgAndroidExampleGLES1 from C:\Local\OpenSceneGraph-Android\examples\osgAndroidExampleGLES1 to your workspace: <workspace>\osgAndroidExampleGLES1; - In Eclipse, File | Import..., expand Android and select Existing Android Code Into Workspace. Next; - In Root Directory browse to <workspace>\osgAndroidExampleGLES1; - Select the projects osg.AndroidExample.osgViewer and hit Finish; - In Eclipse, open up jni\Android.mk and set OSG_ANDROID_DIR to C:\Local\OpenSceneGraph-3.0.1\osginstall on line 7; - You also need to add -lgnustl_static onto the end of line 21 (LOCAL_LDLIBS); If you have an ndk version greater than android-ndk-r8b: - Open C:\Local\OpenSceneGraph-Android\build\AndroidManifest.xml in a text editor; - Add <uses-sdk android:targetSdkVersion="8" android:minSdkVersion="8"></uses-sdk> as a child of '<manifest>'. You should be able to paste it straight into the empty line 6. Finally: - navigate to <workspace>\osgAndroidExampleGLES1 in CMD and run ndk-build; - plug in a device, or launch an emulator, and debug or run the app in Eclipse. We hope this helps! Regards, Nathan Collins Intern Software Engineer ===== Midland Valley Exploration Ltd. 144 West George Street Glasgow G2 2HG United Kingdom Tel: +44 (0) 141 332 2681 Fax: +44 (0) 141 332 6792 The structural geology experts _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org