Compiling Android Cores

hi,

I don’t follow all this thread but for mame build you have to use different ndk.

for mame 2016 you should use ndk 10e . you can look at the buildbot conf file on libretro-super.

make OSD=retro RETRO=1 NOWERROR=1 NOASM=1 gcc=android-arm gcc_version=4.9 TARGETOS=android-arm CONFIG=libretro NO_USE_MIDI=1 OS=linux VERBOSE=1 verbose=1 OVERRIDE_CC=/home/buildbot/tools/android/android-ndk-r10e/toolchains/llvm-3.5/prebuilt/linux-x86_64/bin/clang OVERRIDE_CXX=/home/buildbot/tools/android/android-ndk-r10e/toolchains/llvm-3.5/prebuilt/linux-x86_64/bin/clang++ TARGET=mame -j4

For mame current ndk 13b at least

 make  OSD=retro verbose=1 RETRO=1 NOWERROR=1 NOASM=1 gcc=android-arm OS=linux TARGETOS=android-arm  CONFIG=libretro NO_USE_MIDI=1 TARGET=mame  -j4

for older (2014 and 2010) you just need to setup an android standalone toolchain

make  VRENDER=soft PTR64=0 CC=arm-linux-androideabi-gcc CXX=arm-linux-androideabi-g++ LD=arm-linux-androideabi-g++ platform=android emulator 
3 Likes

Well

Picodrive done and multiple copies up.

Managed to eventually get MAME to compile too but (and there’s always a but…

218mb??? It did zip down to around 70mb so like the current one

My goal is to compile MAME multiple times to allow a custom mame for each system I use - aquarius, intellivision, supervision etc.

I notice it makes just about every system while it compiles so once I get the size down to something more reasonable, I can see if I can strip out unwanted systems to make more “singular” mame compiles.

Passing target=mame or mess is one thing, but can we pass a target of a specific system? that way the build should be smaller. Not sure if it’s possible

Brent

1 Like

Note to self :slight_smile:

Seems /src/mame/drivers has all the drivers for mame including systems

SOURCES=src/mame/drivers/coleco.cpp REGENIE=1

Tried compile with added lines above and it compiled ok, copied across and loaded ok too - will be trying later

My compile works by running (from within libretro-mame folder)…

make -f Makefile.libretro platform=android -j3

1 Like

Thanks for keeping this updated. You doing a sterling job good progression. :smile:

Compiling Libretro Cores for Android on Ubuntu

*** Not saying this is THE way to do it, but it was MY way for getting cores working on the Nvidia Shield - probably an overkill at times :slight_smile: ***

Pre-ramble There is no one size fits all way to compile cores - different versions of NDK,Tools,etc. There is a recipes directory in libretro-super that “kinda” shows exactly whats needed to compile each core. As the guide below stands - I managed to compile 42 of the cores without any juggling - there are some more that compile by specifically naming it - so this guide covers the most part but the files below will allow you to compile more if you are prepared to change some paths later on.

Whats needed: Ubuntu 16.04 running (dedicated or a virtual machine) other flavours do work but this is the goto build.

Android NDK r15c - https://developer.android.com/ndk/downloads/older_releases.html

Android NDK r13b - https://developer.android.com/ndk/downloads/older_releases.html

Android NDK r10e - https://developer.android.com/ndk/downloads/older_releases.html

Android SDK latest - https://developer.android.com/studio/index.html

Android SDK r25.2.5 - https://androidsdkoffline.blogspot.fr/p/android-sdk-tools.html

java-8-openjdk-amd64 - (from terminal) sudo apt install default-jdk

ant - (from terminal) sudo apt install ant

Preliminary steps:

  1. Create a folder “android” in your home directory. <----THIS IS YOUR GOTO FOLDER EVERYTHING IS STORED IN HERE.

  2. Extract Android NDK r15c into folder “android-ndk-r15c” in the android directory.

  3. Extract Android NDK r13b into folder “android-ndk-r13b” in the android directory.

  4. Extract Android NDK r10e into folder “android-ndk-r10e” in the android directory.

  5. Extract Android SDK latest into folder “tools” in the android directory.

  6. Extract Android SDK r25.2.5 into folder “tools_r25.2.5” in the android directory.

  7. Make Standalone toolkit for android-ndk-r15c in folder “stdtc-r15c” and place in android directory.

    • from the android-ndk-r15c/build/tools directory…
    • make_standalone_toolchain.py --arch arm --api 21 --install-dir stdtc-r15c
  8. Make Standalone toolkit for android-ndk-r13b in folder “stdtc-r13b” and place in android directory.

    • from the android-ndk-r13b/build/tools directory…
    • make_standalone_toolchain.py --arch arm --api 21 --install-dir stdtc-r13b
  9. Make Standalone toolkit for android-ndk-r10e in folder “stdtc-r10e” and place in android directory.

    • from the android-ndk-r10e directory…
    • /build/tools/make-standalone-toolchain.sh --toolchain=arm-linux-androideabi-4.9 --platform=android-21 --install-dir=stdtc-r10e
  10. In terminal run (from the android directory) git clone https://github.com/libretro/libretro-super to clone the libretro-super folder

  11. From the newly created libretro-super directory run ./libretro-fetch.sh in terminal and go and grab a coffee (or 3). This will clone all the cores and retroarch and is a fair size.

  12. Finally we need to add the paths to our compiling tools - run from terminal -sudo gedit ~/.bashrc (or your preferred text editor)

*** Add these lines your .bashrc at the end ***

export ANDROID_HOME=~/android/tools_r25.2.5

export NDK_ROOT=~/android/android-ndk-r15c

export ANDROID_NDK=~/android/android-ndk-r15c

export ANDROID_STANDALONE_TOOLCHAIN=~/android/stdtc-r15c

export ANDROID_NDK_ARM=~/android/android-ndk-r15c/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64

export ANDROID_NDK_ROOT=~/android/android-ndk-r15c

export ANDROID_NDK_LLVM=~/android/android-ndk-r15c/toolchains/llvm/prebuilt/linux-x86_64

export TOOLCHAIN=~/android/android-ndk-r15c/toolchains

export ANDROID_TOOL_CHAIN=~/android/android-ndk-r1c/toolchains

export PATH=$PATH:/usr/share/ant/bin

export PATH=$PATH:~/android/stdtc-r15c/bin

export PATH=$PATH:~/android/tools_r25.2.5

export PATH=$PATH:~/android/android-ndk-r15c

export PATH=$PATH:~/android/android-ndk-r15c/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/

export CC=arm-linux-androideabi-gcc

export CXX=arm-linux-androideabi-g++

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

NOW REBOOOOOOOOOOOTTTTT!!!

If you got this far then well done - you now have a working environment to compile cores so lets do just that :slight_smile:

I was only interested in the armeabi-v7a cores so I changed the line in libretro-config.sh (in libretro-super directory) to - export TARGET_ABIS=“armeabi-v7a” - and deleted the other ones - it compiled far quicker for me not compiling unecessary targets. Probably a command line way but this worked.

To compile your first cores…

  1. For me, I need to change the permissions on the file libretro-buid-android-mk.sh in the “libretro-super” directory to allow execute (Allow executing file as program)
  2. From terminal, enter the libretro-super directory and run - ./libretro-buid-android-mk.sh This builds completed cores in the “dist/android/armeabi-v7a” directory. As previously stated some fail but I managed to get 42 cores compiled this way off the bat.

To get cores onto your Retroarch install… Cores need to be zipped and then moved onto your Retroarch.

Easiest way to do this (and it works on an non-rooted Shield) is to follow Thatman84’s excellent guide for creating an local updater here - http://emulationguide.com/retroarch-local-online-updater.

That should be that for now. Your next steps in exploration should be to look at the recipes and see what cores are compiled using different toolchains.

my .bashrc has multiple sections commented out (use a #) the one below is for the r13b NDK for example, some versions of mame if I recall prefer the older r10 version too. I just comment out all but the version I want to use and reboot.

export ANDROID_HOME=~/android/tools_r25.2.5

export NDK_ROOT=~/android/android-ndk-r13b

export ANDROID_NDK=~/android/android-ndk-r13b

export ANDROID_STANDALONE_TOOLCHAIN=~/android/stdtc-r13b

export ANDROID_NDK_ARM=~/android/android-ndk-r13b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64

export ANDROID_NDK_ROOT=~/android/android-ndk-r13b

export ANDROID_NDK_LLVM=~/android/android-ndk-r13b/toolchains/llvm/prebuilt/linux-x86_64

export TOOLCHAIN=~/android/android-ndk-r13b/toolchains

export ANDROID_TOOL_CHAIN=~/android/android-ndk-r13b/toolchains

export PATH=$PATH:/usr/share/ant/bin

export PATH=$PATH:~/android/stdtc-r13b/bin

export PATH=$PATH:~/android/tools_r25.2.5

export PATH=$PATH:~/android/android-ndk-r13b

export PATH=$PATH:~/android/android-ndk-r13b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/

export CC=arm-linux-androideabi-gcc

export CXX=arm-linux-androideabi-g++

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

I do have a google sheet that I have noted what compiled best for me and how I acheived it - I would be willing to share that with anyone interested.

So to sign out - I am not saying this is THE way and no doubt I added unecessary steps but if you followed this guide to the letter you certainly “should” have compiled cores sitting on your pc :slight_smile:

If people try this guide sucessfully please let me know and I will offer it to update the docs. Also if anyone has any improvements please share too :slight_smile:

Brent

1 Like

One last quicky.

for updating things:

In terminal enter your libretro-super directory and type git pull to update the main directory.

again in terminal (still in same folder) type ./libretro-fetch.sh to update the cores etc.

Brent

1 Like

Hi @brentg,would you mind compile two arm-v7a cores for me? I’ve tried compile cores on android but failed and I don’t have available compile environment on my old windows pc and don’t know how to use Linux.

Can I use this method to compile the mame core? There is no mame in WANT_CORES section (libretro-build-android-mk.sh),just found mame2000 and mame2003