Android build: Difference between revisions

From OpenMW Wiki
Jump to navigation Jump to search
Line 72: Line 72:


=== Building OpenMW ===
=== Building OpenMW ===
then I started to build OpenMW. At first you must remove all lines associated with x server in FindOGRE.cmake
Then I started to build OpenMW.  
and add GLES2 instead GLES .
I copied all  libraries  in one folder . For example AndroidDependencies, and build openmw like this
For example
<syntaxhighlight lang="cmake">
ogre_find_plugin(RenderSystem_GLES2 OgreGLES2RenderSystem.h RenderSystems/GLES2/include)
</syntaxhighlight>
next I add this to main cmake file:
<syntaxhighlight lang="cmake">
set(CMAKE_FIND_ROOT_PATH ${OPENMW_DEPENDENCIES_DIR} "${CMAKE_FIND_ROOT_PATH}")
</syntaxhighlight>


And now I can build OpenMW with it
cmake /home/sylar/openmw -DCMAKE_TOOLCHAIN_FILE=/home/sylar/android-cmake-master/android.toolchain.cmake  
<syntaxhighlight lang="bash">
-DOPENMW_DEPENDENCIES_DIR=/home/sylar/AndroidDependencies -DANDROID_NATIVE_API_LEVEL=14
cmake /home/sylar/openmw -DCMAKE_TOOLCHAIN_FILE=/home/sylar/android-cmake-master/android.toolchain.cmake -DOPENMW_DEPENDENCIES_DIR=/home/sylar/AndroidDependencies -DANDROID_NATIVE_API_LEVEL=14
</syntaxhighlight>
next I remove line from main cmake file:
<syntaxhighlight lang="cmake">
add_static_ogre_plugin(RenderSystem_GL)
</syntaxhighlight>
and add it
<syntaxhighlight lang="cmake">
add_static_ogre_plugin(RenderSystem_GLES2)
</syntaxhighlight>
Next I add I remove line
<syntaxhighlight lang="cmake">
add_library(openmw executable
    ${OPENMW_LIBS} ${OPENMW_LIBS_HEADER}
    ${OPENMW_FILES}
    ${GAME} ${GAME_HEADER}
    ${APPLE_BUNDLE_RESOURCES}
)
</syntaxhighlight>
in /openmw/apps/openmw/Cmakelists.txt
and add it
<syntaxhighlight lang="cmake">
add_library(main SHARED
    ${OPENMW_LIBS} ${OPENMW_LIBS_HEADER}
    ${OPENMW_FILES}
    ${GAME} ${GAME_HEADER}
    ${APPLE_BUNDLE_RESOURCES}
)
</syntaxhighlight>
also I add it
<syntaxhighlight lang="cmake">
set(GAME
    main.cpp
    SDL_android_main.c
    engine.cpp
)
#//if(NOT WIN32)
# //  set(GAME ${GAME} crashcatcher.cpp)
#endif()


# Main executable
In building, you will have bug with pthread library .
set(BOOST_COMPONENTS system filesystem program_options thread wave atomic)
target_link_libraries(main


${OGRE_STATIC_PLUGINS}
I solved this problem as follows . I found this file
#RenderSystem_GLES2Static
/home/sylar/openmw21/apps/openmw/CMakeFiles/openmw.dir/link.txt
#//Plugin_OctreeSceneManagerStatic
#//Plugin_ParticleFXStatic
#  ${OGRE_Plugin_OctreeSceneManager_LIBRARY_REL} 
# ${OGRE_Plugin_ParticleFX_LIBRARY_REL}   
#${OGRE_RenderSystem_GLES2_LIBRARY_REL} 
)


and change -lpthread on -pthread


target_link_libraries(main
After builing openmw library, you must copy all the libraries to libs folder in the  java project folder
EGL
android
log
dl


#  ${OGRE_Plugin_OctreeSceneManager_LIBRARY_REL} 
For example : /eclipse-project/app/src/main/jniLibs/armeabi-v7a
  # ${OGRE_Plugin_ParticleFX_LIBRARY_REL}   
#${OGRE_RenderSystem_GLES2_LIBRARY_REL} 
)
target_link_libraries(main
boost_atomic
boost_chrono
boost_date_time
boost_filesystem
boost_program_options
boost_system
boost_thread
boost_wave
#  ${OGRE_Plugin_OctreeSceneManager_LIBRARY_REL} 
# ${OGRE_Plugin_ParticleFX_LIBRARY_REL}   
#${OGRE_RenderSystem_GLES2_LIBRARY_REL} 
)
target_link_libraries(main
FreeImage
freetype
#  ${OGRE_Plugin_OctreeSceneManager_LIBRARY_REL} 
# ${OGRE_Plugin_ParticleFX_LIBRARY_REL}   
#${OGRE_RenderSystem_GLES2_LIBRARY_REL} 
)


target_link_libraries(main
Then you must import this [https://github.com/OpenMW/eclipse-project java project] in android-studio , which included with the android sdk.
OgreMainStatic
#  ${OGRE_Plugin_OctreeSceneManager_LIBRARY_REL} 
# ${OGRE_Plugin_ParticleFX_LIBRARY_REL}   
#${OGRE_RenderSystem_GLES2_LIBRARY_REL} 
)


target_link_libraries(main
Also you need to import the configuration files from desktop openmw version.
MyGUI.OgrePlatform
MyGUIEngineStatic
Plugin_StrangeButtonStatic
cpufeatures
#  ${OGRE_Plugin_OctreeSceneManager_LIBRARY_REL} 
# ${OGRE_Plugin_ParticleFX_LIBRARY_REL}   
#${OGRE_RenderSystem_GLES2_LIBRARY_REL} 
)
</syntaxhighlight>
Next I changed paths in: /openmw/components/files/linuxpath.cpp
for example
<syntaxhighlight lang="cpp">
return getEnv("XDG_DATA_HOME", "/sdcard/morrowind/share") / mName;
</syntaxhighlight>
Next I add patch in ogreinit.cpp and ogreinit.hpp
I comment it
<syntaxhighlight lang="cpp">
// Set up logging first
  //    new Ogre::LogManager;
    //  Ogre::Log *log = Ogre::LogManager::getSingleton().createLog(logPath);
 
  // #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
        // Use custom listener only on Windows
      // log->addListener(new LogListener(logPath));
//  #endif
 
        // Disable logging to cout/cerr
      // log->setDebugOutputEnabled(false);
</syntaxhighlight>
and change plugin gl on gles2
<syntaxhighlight lang="cpp">
#ifdef ENABLE_PLUGIN_GLES2
# include "OgreGLES2Plugin.h"
#endif
 
#ifdef ENABLE_PLUGIN_GLES2
        Ogre::GLES2Plugin* mGLES2Plugin;
#endif
</syntaxhighlight>
Next you must add it to
<syntaxhighlight lang="cpp">
opt["externalWindowHandle"] = Ogre::StringConverter::toString((int) wmInfo.info.android.window );
opt["externalSurface"] = Ogre::StringConverter::toString((int) wmInfo.info.android.surface );
</syntaxhighlight>
  /openmw/extern/sdl4ogre/sdlwindowhelper.cpp
Next I add this file to OpenMW
SDL_android_main.c
With it, I calle native c code from java wtih help jni .
I rename main function in main.cpp to SDL_main .
 
Now you can build openmw lib
 
Next for eclipse project I use android-project example from SDL
and use README-android.txt tutorial from sdl

Revision as of 18:11, 14 June 2015

Android build OpenMW

Preparation of building environment

Before you start building OpenMW on Android you have to do few steps of preparation:

  1. Download Crystax NDK
  2. Download and install Google Android SDK
  3. Download Cmake for Android (it will be used for OpenMW and its dependencies compilation)
  4. Download java
  5. Download all OpenMW dependencies, ie:

Compilation of OpenMW dependencies

Then you should add PATH for crystax ndk and google sdk.

Building OSG

Next you must build OSG from source. I build osg with this tutorials . http://www.openscenegraph.org/index.php/documentation/platform-specifics/android/43-building-openscenegraph-for-android-3-0-2 http://www.openscenegraph.org/index.php/documentation/platform-specifics/android/178-building-openscenegraph-for-android-3-4 You must build osg with osgdb_dds osgdb_bmp, osgdb_tga ,osgdb_gif ,osgdb_jpeg, osgdb_png plugins and GLES2 profile !

Building MyGUI

Then you must build mygui with 1 rendering system

Building Bullet

Then you should build bullet2. You can use cmake android toolchain for it

Building OpenAL

Then you must build openal . http://repo.or.cz/w/openal-soft/android.git

Building Qt (optional)

Note: Qt is only used by the launcher and OpenMW-CS, and can be skipped. To build Qt 4.8 for android: http://necessitas.kde.org/ I used this tutorial for building: https://community.kde.org/Necessitas/CompileQtFramework

Building FFmpeg

Then you must build ffmpeg . Important! You must use ffmpeg 1.26: http://www.roman10.net/how-to-build-ffmpeg-with-ndk-r9/

my script for build

./configure \
    --prefix=$(pwd)/android/$CPU  \
    --enable-static \
    --disable-doc \
    --disable-ffmpeg \
    --disable-ffplay \
    --disable-ffprobe \
    --disable-ffserver \
    --disable-doc \
    --disable-symver \
    --cross-prefix=/home/sylar/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/bin/arm-linux-androideabi- \
    --target-os=linux \
    --arch=arm \
    --enable-asm \
    --enable-cross-compile \
    --sysroot=/home/sylar/android-ndk-r9d/platforms/android-19/arch-arm \
    --extra-cflags="-Os -fpic $ADDI_CFLAGS" \
    --extra-ldflags="$ADDI_LDFLAGS"

Building SDL2

Then you must build SDL2: https://www.libsdl.org/hg.php I used SDL2 mercurial latest source.

Building OpenMW

Then I started to build OpenMW. I copied all libraries in one folder . For example AndroidDependencies, and build openmw like this

cmake /home/sylar/openmw -DCMAKE_TOOLCHAIN_FILE=/home/sylar/android-cmake-master/android.toolchain.cmake -DOPENMW_DEPENDENCIES_DIR=/home/sylar/AndroidDependencies -DANDROID_NATIVE_API_LEVEL=14

In building, you will have bug with pthread library .

I solved this problem as follows . I found this file /home/sylar/openmw21/apps/openmw/CMakeFiles/openmw.dir/link.txt

and change -lpthread on -pthread

After builing openmw library, you must copy all the libraries to libs folder in the java project folder

For example : /eclipse-project/app/src/main/jniLibs/armeabi-v7a

Then you must import this java project in android-studio , which included with the android sdk.

Also you need to import the configuration files from desktop openmw version.