Skip to content

Compilation guide (android from windows)

Jean-Sébastien Guay edited this page Jul 4, 2013 · 8 revisions

Prerequisites

You need a complete android development environment ready to develop native apps. That means:

  • Cygwin
  • Android SDK
  • Android NDK
  • Eclipse with appropriate plugins

Use Google to figure out how to install all that. Everything in this page happens in a Cygwin shell and in Eclipse. Make sure you set NDK_ROOT to the path to your NDK and add that to your PATH in the Cygwin shell. For example, edit your .bashrc to add these lines:

export NDK_ROOT=/cygdrive/d/Dev/Libs/Android/android-ndk-r8e
export PATH=$NDK_ROOT:$PATH

Building libretro cores

git clone https://github.com/libretro/libretro-super.git
cd libretro-super
./libretro-fetch.sh              # can fail on fork() calls, repeat until all are up to date
./libretro-build-android.sh      # some cores may fail to compile (g++ "Argument list too long" error)
                                 # see https://github.com/libretro/libretro-super/issues/10

Building RetroArch

git clone https://github.com/Themaister/RetroArch.git
cd RetroArch/android/native
ndk-build clean; ndk-build                # build native libs
cd ../phoenix
mkdir libs
cp -R ../native/libs/* libs                     # copy native libs
cp -R ../../../libretro-super/dist/* libs    # copy libretro cores
cp -R ../../media/overlays/* assets/Overlays    # copy overlays

When you need to rebuild the native code, run this from RetroArch/android/native:

ndk-build; /bin/cp -R -f libs/* ../phoenix/libs

In Eclipse, set your workspace root to .../RetroArch/android. Then do "Import... - General - Existing Projects into Workspace" to get the native and phoenix projects in your workspace. I also copied the project.properties from phoenix to native, and created a src directory in native, to stop Eclipse from complaining, but that may just be because I'm using a really old version.

Then, when you want to deploy to your device (make sure USB debugging is enabled) right-click on the phoenix project and select "Run As - Android Application" or use Debug to attach the debugger. When the native libs change I will tend to Clean before doing Run, to make sure the libs were repackaged in the apk. Google for more info about running and debugging Android apps in Eclipse.