[Tutorial] Building Ogre3d 1.9 for Android in Ubuntu Linux

Problems building or running the engine, queries about how to use features etc.
Post Reply
anibaleon1989
Gnoblar
Posts: 2
Joined: Thu Apr 17, 2014 12:56 am

[Tutorial] Building Ogre3d 1.9 for Android in Ubuntu Linux

Post by anibaleon1989 » Thu Apr 17, 2014 1:09 am

The tutorial shown below will allow you to compile Ogre3D 1.9 to Android on a Linux system. Upon completion, the user will get a sample apk you can install on your Android device.
Note: Although the tutorial has been made in 64-bit Ubuntu 12.04 , is compatible with other Linux-based systems.

Previous Packages needed :
-> Install open-jdk ( apt-get install openjdk-7-jdk )
-> Install cmake ( apt-get install cmake )
If you need any more package , the system will warn you , the last two are the most important .

Tools required :
-> Adt-bundle-linux (Download the latest version which you can find on http://developer.android.com/tools/sdk/eclipse-adt.html , this is the android sdk with eclipse) .
-> AndroidDependencies_27_08_2013.zip ( Available in http://sourceforge.net/projects/ogre/fi ... droid/1.9/ )
-> Android-ndk-R8C-linux-x86.tar.bz2 (Use this version whether the system is 32 as if it is 64 bits, available in http://dl.google.com/android/ndk/androi ... 86.tar.bz2 )
-> Sinbad-ogre-e390b8258d19 (Download the source version 1.9 (no precompile ), available at https://bitbucket.org/sinbad/ogre/src/4 ... ?at=v1-9-0 )

Directory structure :
- Create a folder /home/<user>/Android
- Unzip in the previous folder the tools adt-bundle , android-ndk and sinbad-ogre . Therefore the directory tree will be :
/ home
........./ <user>
................/ Android
................/ eclipse
................/ android-ndk-R8C
................/ sdk
................/ ogre ---By default "ogre" folder is called sinbad-ogre-e390b8258d19 or similar
- Now unzip AndroidDependencies in /home/<user>/ogre
/ home
........./ <user>
................/ Android
................/ eclipse
................/ android-ndk-R8C
................/ sdk
................/ ogre
........................../ AndroidDependencies

Creating environment variables :
Edit the file home/<user>/.Bashrc or home/<user>/.Bash_profile ( which there of the two )
to do this "sudo gedit home/<user>/.bashrc " or "sudo gedit home/<user>/.profile " and add the following 3 lines to the end of the file :
export PATH=/home/<user>/Android/sdk/tools:/home/<user>/Android/sdk/platform-tools:/home/<user>/Android/android-ndk-r8c:$PATH
ANDROID_NDK export = /home/<user>/Android/android-ndk-r8c
ANDROID_SDK export = /home/<user>/Android/sdk

Compilation with CMake :
Now comes the really important
1st We must run cmake-gui , ie cmake GUI . We can use the icon or write cmake-gui in the terminal.
2nd Where it says "Where is the source code" we put the path to Ogre, in my case , /home/<user>/Android/ogre . Then, just below where it says "Where to build the binaries" write the above path by adding /build. Would be /home/<user>/Android/ogre/build

At this time we will press set , accept the creation of the build directory , select Unix Makefiles and choose "Specify toolchain file for cross-compiling ." By clicking continue , you are prompted for the path of the toolchain , which in our case is /home/<user>/Android/ogre/CMake/toolchain/android.toolchain.cmake
By clicking on done, try compiling done , but give errors.

3rd Then hit Add Entry and write ANDROID_NDK in the first field. PATH select from the drop , and finally put the path to the NDK , in our case /home/<user>/Android/android-ndk-r8c
Again press Add Entry , this time we write OGRE_DEPENDENCIES_DIR , the type we also PATH , and the android path dependencies : /home/<user>/Android/ogre/AndroidDependencies
(Remember adapt all routes with your username instead of <user> and the directory structure of your choice ) .

Again click on configure , and although fewer errors appear , is not entirely correct.

To fix the remaining errors have to change the next item in the dropdown that appears in the CMake interface :
ANDROID_NATIVE_API_LEVEL -> We must change the value to 9

Once done , you press on the set , the configuration will be performed again , this time without errors (I hope ) .

We can now click on generate. Once we do, we will open a terminal , travel to the build directory within ogre ( cd /home/<user>/Android/ogre/build ) and execute the " make -j4 " command
( Surely some mistake will be shown during compilation. This will be fixed by running the command several times , usually 2 or 3).

Finally, to test the sample , we will go to the SampleBrowserNDK folder ( cd /home/<user>/Android/ogre/build/SampleBrowserNDK ) and run :
ndk-build all -j4
android update project --target "android-10" --path ./
( The above command will replace the number 10 from eclipse installed with the sdk manager version). I recommend installing version 10, for this we go to /home/<user>/eclipse and we double click on the file eclipse . Eclipse interface opens and just travel to window->android-sdk-manager and install the packages that are within "Android 2.3.3 (API 10)."
Finally , with our device connected and debug mode active therein, run the "ant debug install" command that we install the sample application into the device.

In the next tutorial, a sample project in which we will use Ogre3D to Android, including through physical Bullet, which will be added as another library through Android NDK.

Aníbal León, student at the University of Castilla la Mancha, Spain. Contact: anibaleon1989@gmail.com / http://www.allsof.com
0 x

User avatar
Herb
Orc
Posts: 412
Joined: Thu Jun 04, 2009 3:21 am
Location: Kalamazoo,MI
x 1

Re: [Tutorial] Building Ogre3d 1.9 for Android in Ubuntu Lin

Post by Herb » Thu Apr 17, 2014 11:42 am

Thanks anibaleon1989 for putting this together. Android with Ogre has been on my list to play with, but there haven't been instructions to set it up on Linux. Need to get these instructions up on the wiki. :)
0 x

anibaleon1989
Gnoblar
Posts: 2
Joined: Thu Apr 17, 2014 12:56 am

Re: [Tutorial] Building Ogre3d 1.9 for Android in Ubuntu Lin

Post by anibaleon1989 » Fri Apr 18, 2014 12:51 am

Thank you very much for your answer.
I just hope this tutorial will serve more people and write your questions and problems to troubleshoot.

A greeting.
0 x

AYYAN
Greenskin
Posts: 117
Joined: Wed May 09, 2007 8:55 am

Re: [Tutorial] Building Ogre3d 1.9 for Android in Ubuntu Lin

Post by AYYAN » Sat Aug 30, 2014 5:22 pm

Hi Aníbal León

Thank you so much for your step by step guide to compile Ogre for Android in Ubuntu Linux. It works excellent. Able to view SampleBrower running at my Android device. I am back to Ogre after a long gap, But this time is to Ogre for android in Linux. It would be good if we have tutorials of Ogre for Android. I would like to have a tutorial from you on it. This would be great help for everyone trying to move to android platform like me. Thanks everyone in this community to keep supporting wonderful 3D engine Ogre and now to Ogre for Android.

Please share reference here if you find and good tutorials to create ogre project for android in linux. I also will do it.
0 x

bachnv
Gnoblar
Posts: 3
Joined: Fri Sep 19, 2014 9:10 am

Re: [Tutorial] Building Ogre3d 1.9 for Android in Ubuntu Lin

Post by bachnv » Fri Sep 19, 2014 9:19 am

When I reach to 100% percentage, I met bellow error

Code: Select all

[100%] Built target OgreTerrain
[100%] Building CXX object CMakeFiles/OgreJNIDummy.dir/dummyJNI.cpp.o
Linking CXX shared module lib/libOgreJNIDummy.so
Updated project.properties
Updated local.properties
Updated file /home/4000073/Android/sinbad-ogre-f5a1b5c87545/build/OgreJNI/proguard-project.txt
Android NDK: WARNING:jni/Android.mk:OgreJNI: non-system libraries in linker flags: -lPlugin_ParticleFXStatic -lPlugin_OctreeSceneManagerStatic -lRenderSystem_GLES2Static -lOgreRTShaderSystemStatic -lOgreOverlayStatic -lOgreTerrainStatic -lOgrePagingStatic -lOgreVolumeStatic -lOgreMainStatic -lzzip -lFreeImage -lfreetype -lOIS /home/4000073/Android/sinbad-ogre-f5a1b5c87545/build/systemlibs/armeabi-v7a/libsupc++.a /home/4000073/Android/sinbad-ogre-f5a1b5c87545/build/systemlibs/armeabi-v7a/libstdc++.a /home/4000073/Android/sinbad-ogre-f5a1b5c87545/build/OgreJNI/obj/local/armeabi-v7a/libcpufeatures.a    
Android NDK:     This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES    
Android NDK:     or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the    
Android NDK:     current module    
[armeabi-v7a] SharedLibrary  : libOgreJNI.so
/home/4000073/Android/android-ndk-r9b/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lOgreOverlayStatic
/home/4000073/Android/android-ndk-r9b/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi-v7a/objs/OgreJNI/OgreActivityJNI.o: in function Java_org_ogre3d_android_OgreActivityJNI_create:/home/4000073/Android/sinbad-ogre-f5a1b5c87545/OgreMain/include/Android/OgreAPKZipArchive.h:43: error: undefined reference to 'Ogre::EmbeddedZipArchiveFactory::EmbeddedZipArchiveFactory()'
/home/4000073/Android/android-ndk-r9b/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: /home/4000073/Android/sinbad-ogre-f5a1b5c87545/build/lib/libOgreMainStatic.a(OgreAPKZipArchive.cpp.o): in function Ogre::APKZipArchiveFactory::~APKZipArchiveFactory():/home/4000073/Android/sinbad-ogre-f5a1b5c87545/OgreMain/include/Android/OgreAPKZipArchive.h:44: error: undefined reference to 'Ogre::EmbeddedZipArchiveFactory::~EmbeddedZipArchiveFactory()'
/home/4000073/Android/android-ndk-r9b/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: /home/4000073/Android/sinbad-ogre-f5a1b5c87545/build/lib/libOgreMainStatic.a(OgreAPKZipArchive.cpp.o): in function Ogre::APKZipArchiveFactory::~APKZipArchiveFactory():/home/4000073/Android/sinbad-ogre-f5a1b5c87545/OgreMain/include/Android/OgreAPKZipArchive.h:44: error: undefined reference to 'Ogre::EmbeddedZipArchiveFactory::~EmbeddedZipArchiveFactory()'
/home/4000073/Android/android-ndk-r9b/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: /home/4000073/Android/sinbad-ogre-f5a1b5c87545/build/lib/libOgreMainStatic.a(OgreAPKZipArchive.cpp.o): in function Ogre::APKZipArchiveFactory::createInstance(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool):/home/4000073/Android/sinbad-ogre-f5a1b5c87545/OgreMain/include/Android/OgreAPKZipArchive.h:59: error: undefined reference to 'Ogre::EmbeddedZipArchiveFactory::addEmbbeddedFile(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned char const*, unsigned int, bool (*)(unsigned int, void*, unsigned int))'
/home/4000073/Android/android-ndk-r9b/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: /home/4000073/Android/sinbad-ogre-f5a1b5c87545/build/lib/libOgreMainStatic.a(OgreAPKZipArchive.cpp.o): in function Ogre::APKZipArchiveFactory::createInstance(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool):/home/4000073/Android/sinbad-ogre-f5a1b5c87545/OgreMain/include/Android/OgreAPKZipArchive.h:62: error: undefined reference to 'Ogre::ZipArchive::ZipArchive(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, _zzip_plugin_io*)'
/home/4000073/Android/android-ndk-r9b/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: /home/4000073/Android/sinbad-ogre-f5a1b5c87545/build/lib/libOgreMainStatic.a(OgreAPKZipArchive.cpp.o): in function Ogre::APKZipArchiveFactory::createInstance(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool):/home/4000073/Android/sinbad-ogre-f5a1b5c87545/OgreMain/include/OgreMemoryNedPooling.h:77: error: undefined reference to 'Ogre::EmbeddedZipArchiveFactory::mPluginIo'
/home/4000073/Android/android-ndk-r9b/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: /home/4000073/Android/sinbad-ogre-f5a1b5c87545/build/lib/libOgreMainStatic.a(OgreAPKZipArchive.cpp.o): in function typeinfo for Ogre::APKZipArchiveFactory:OgreAPKZipArchive.cpp(.data.rel.ro._ZTIN4Ogre20APKZipArchiveFactoryE+0x8): error: undefined reference to 'typeinfo for Ogre::EmbeddedZipArchiveFactory'
collect2: ld returned 1 exit status
make[3]: *** [obj/local/armeabi-v7a/libOgreJNI.so] Error 1
make[2]: *** [lib/libOgreJNIDummy.so] Error 2
make[1]: *** [CMakeFiles/OgreJNIDummy.dir/all] Error 2
make: *** [all] Error 2

Anyone can help?
Thank you very much!
0 x

User avatar
Argosse
Gnoblar
Posts: 17
Joined: Wed Apr 27, 2011 9:43 pm

Re: [Tutorial] Building Ogre3d 1.9 for Android in Ubuntu Lin

Post by Argosse » Wed Dec 24, 2014 8:13 pm

Take those libraries it complained about being in the linker and go to the Android.mk file,
instead of

Code: Select all

LOCAL_LDLIBS += -lPlugin_ParticleFXStatic -lPlugin_OctreeSceneManagerStatic
LOCAL_LDLIBS += -lRenderSystem_GLES2Static -lOgreRTShaderSystemStatic
add a line

Code: Select all

LOCAL_STATIC_LIBRARIES += libPlugin_ParticleFXStatic libPlugin_OctreeSceneManagerStatic libRenderSystem_GLES2Static
you may have to fiddle with how they are named in there but that should fix it
0 x

Post Reply