How to compile Lua 5.3.0 for Android as a dynamic library
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.
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
4. Left click on this new folder and select New->File
name it Android.mk and paste this into
1 2 3 4 5 6 7 8 9 10 11 12 |
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_ARM_MODE := arm LOCAL_CFLAGS := -D"l_getlocaledecpoint()='.'" -DLUA_ANSI LOCAL_MODULE := liblua LOCAL_SRC_FILES := lua/src/lapi.c lua/src/lauxlib.c lua/src/lbaselib.c lua/src/lbitlib.c lua/src/lcode.c lua/src/lcorolib.c lua/src/lctype.c lua/src/ldblib.c lua/src/ldebug.c lua/src/ldo.c lua/src/ldump.c lua/src/lfunc.c lua/src/lgc.c lua/src/linit.c lua/src/liolib.c lua/src/llex.c lua/src/lmathlib.c lua/src/lmem.c lua/src/loadlib.c lua/src/lobject.c lua/src/lopcodes.c lua/src/loslib.c lua/src/lparser.c lua/src/lstate.c lua/src/lstring.c lua/src/lstrlib.c lua/src/ltable.c lua/src/ltablib.c lua/src/ltm.c lua/src/lundump.c lua/src/lutf8lib.c lua/src/lvm.c lua/src/lzio.c include $(BUILD_SHARED_LIBRARY) |
5. Repeat step 4. and create a file in the same jni folder called Application.mk and fill it with
1 2 3 |
APP_ABI := armeabi armeabi-v7a x86 |
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
8. navigate with a terminal to your root project folder and type
1 2 3 |
C:\Android\android-ndk-r10d\ndk-build |
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.
7 Comments to How to compile Lua 5.3.0 for Android as a dynamic library
Hello – any progress on the Android Studio version? Thank you.
April 7, 2015
Android Studio uses Gradle for the build process which I didn’t had time to look at yet, sorry
January 19, 2016
Hope there will be an Android Studio version
July 26, 2016
Can you please upload liblua.so to github or to somewhere else. Thanks a lot.
July 28, 2016
You’ll find 5.3.0 dlls/so/etc in my VerySimpleLua repo:
https://github.com/Dennis1000/verysimplelua/tree/master/DLL
November 16, 2016
Where do I put the lua files that I run with luaL_dofile?
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?
Leave a comment
About Dennis D. Spreen
Search
Recent Posts
- How to compile Lua 5.4.0 for Android as a dynamic library using Android Studio 4
- Please make inline vars usable for production – fix RSP-28892
- How to compile Lua 5.4.0 as a Mac OS X dynamic library
- How to compile Lua 5.4.0 for Linux as a shared library
- How to compile Lua 5.4.0 for Windows
- Daily Wage – a Spigot/Bukkit plugin that pays out a daily wage
- How to compile Lua 5.3.5 for Windows
- Better Collada exporter for Blender with custom properties
- MOS6502-delphi – a MOS 6502 CPU emulator for Delphi
- Pass a multidimensional array as a parameter (with a hidden caveat)
Categories
Tags
Archives
- May 2020
- March 2020
- June 2019
- March 2017
- August 2016
- July 2016
- June 2016
- January 2016
- September 2015
- February 2015
- January 2015
- October 2014
- September 2014
- August 2014
- May 2014
- March 2014
- February 2014
- November 2011
- June 2011
- February 2011
- March 2010
- September 2009
- August 2009
- July 2009
- May 2009
- March 2009
- February 2009
- January 2009
- November 2008
- October 2008
- February 2008
- June 2007
Delphi Feeds
- Picking the City Name of the Next Version of Delphi April 18, 2025
- Help Us Choose The Name of The Next RAD Studio April 18, 2025
- Grumpy Old Developer Yells At Clouds Part 2 April 17, 2025
- Using Local LLMs with Smart CodeInsight in RAD Studio April 17, 2025
- Delphi “array of const” to “varargs” – Stack Overflow April 16, 2025
- Visuino at Maker Faire LA 2025 April 16, 2025
- Where Can I Get an Idea for AI Functionality in My Product? – Or Stop Bombarding Me with AI! April 15, 2025
- Whats New in TMS BIZ April 2025 Release April 15, 2025
- TMS Dashboard Updated: Enhancements for an Optimized User Experience April 15, 2025
- Hotfix available: CodeSnip bug fix fix April 14, 2025
March 28, 2015