How to compile Lua 5.4.0 for Linux as a shared library

Sunday, May 24th, 2020 | Dennis D. Spreen | Linux, Lua

This is a tutorial on how to compile Lua 5.4.0 for Linux as a shared library.

This tutorial on how to build Lua for Linux is based on the Stack Overflow question Compiling Lua create .so files? and the answers by @dcarrith and @simonemainardi  – for or a complete makefile take a look there!

This is just a quick hack to spill out a shared library therefore the make file isn’t complete in terms of clean up and testing.

1. Download and extract the Lua 5.4.0 source code

2. Edit the src/makefile and add the last line shown below “$(CC) -shared..” directly under the “$(RANLIB) $@” line. Be sure to use TAB for spacing!

3. Open a terminal, navigate to the base folder and run

You should now have a liblua5.4.0.so shared library in the src/ folder.

Tags: , , , ,

3 Comments to How to compile Lua 5.4.0 for Linux as a shared library

Ali
December 31, 2020

Thanks.

marslo
January 5, 2024

thanks a lot !!
I’ve created the patch for [v5.4.6](https://gist.github.com/marslo/767e339e32e0dbc038a3e00e3c8a7cba)

Dennis
January 5, 2024

@marslo Thanks for the patch!

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