How to compile Lua 5.3.0 for Android as a dynamic library

Monday, January 26th, 2015 | Dennis D. Spreen | Android, Lua

This is a tutorial on how to compile Lua 5.3.0 for Android as a dynamic library (liblua.so) using the Windows Eclipse ADT.

This tutorial is based on the deprecated Eclipse ADT bundle which is now replaced by Android Studio. A tutorial using Android Studio will follow.

1. download and extract Eclipse ADT with the Android SDK for Windows (with a single download, the Eclipse ADT bundle includes everything you need) to C:\Android\adt-bundle-windows-x86-20140702\, then download and extract the current Android NDK for Windows to C:\Android\android-ndk-r10d\ – if not yet done (use your paths accordingly if installed in other directories).

2. run Eclipse ADT (C:\Android\adt-bundle-windows-x86-20140702\eclipse\eclipse.exe) and create a new project with File->New->Android Application Project, fill in some Application, project and package names, use the blank activity template (leave default workspace setting as C:\users\%yourusername%\workspace)

3. Left click on your project then select New -> Folder and choose jni as the folder name

eclipse1



4. Left click on this new folder and select New->File

eclipse2


name it Android.mk and paste this into

5. Repeat step 4. and create a file in the same jni folder called Application.mk and fill it with

By default, the NDK build system will generate machine code only for the armeabi ABI. This corresponds to an ARMv5TE based CPU with software floating point operations. You can use APP_ABI to select a different ABI – the above APP_ABI definition creates 3 libraries with support for a ARMv5TE CPU, a ARMv7 with hardware FPU instructions and x86 devices. Use all for building all ABIs.

6. Download Lua 5.3.0 source and extract it into the jni/ folder, then rename the lua-5.3.0 folder to lua

7. Back in Eclipse with a Refresh on the jni folder should update your directory and file structure like this

ecplise_lua_1


8. navigate with a terminal to your root project folder and type

to compile liblua for Android.

9. After a successful compilation you’ll find the liblua.so libraries in the appropriate folder in the libs\ folder.

 

Tags: ,

7 Comments to How to compile Lua 5.3.0 for Android as a dynamic library

CameraCornet
March 28, 2015

Hello – any progress on the Android Studio version? Thank you.

Dennis
April 7, 2015

Android Studio uses Gradle for the build process which I didn’t had time to look at yet, sorry

Need a android studio version
January 19, 2016

Hope there will be an Android Studio version

Miguel Henley
July 26, 2016

Can you please upload liblua.so to github or to somewhere else. Thanks a lot.

Dennis D. Spreen
July 28, 2016

You’ll find 5.3.0 dlls/so/etc in my VerySimpleLua repo:
https://github.com/Dennis1000/verysimplelua/tree/master/DLL

MyLegGuy
November 16, 2016

Where do I put the lua files that I run with luaL_dofile?

Brian Andersen
February 4, 2019

Hi Dennis.

Am I the lucky one ;o)

I’ve almost started my own scripting engine project until I stumbled on LUA.

I’m very excited to see that you have integrated this project into Delphi.

Would there be any chance for you to compile the latest version and update GITHUB?

https://www.lua.org/ftp/lua-5.3.5.tar.gz

Leave a comment

About Dennis D. Spreen

I'm an avid programmer working on a variety of platforms in a variety of languages with a wide technical interest.

Search

QR Code

Categories