Building Lua 5.3 on macOS
Posted on January 12, 2013 by Sol
Updated 7 October 2017
If you want to build yourself the latest Lua on macOS there is a simple recipe for this:
- Start by downloading the Lua source code from http://www.lua.org/ftp/.
- Extract the archive (I did this in my Downloads folder).
- Open a Terminal and navigate to the Lua source code:
1 cd Downloads 2 cd lua-*
- Decide where you want to install Lua on your system, the default is /usr/local. My recommendation is to install Lua in /usr/local/lua-5.3.
- Build and install Lua:
1 sudo make macosx install INSTALL_TOP=/usr/local/lua-5.3
In order to be able to use Lua, we’ll need to add the interpreter to our system path, paste the next line in a Terminal:
1 export PATH=/usr/local/lua-5.3/bin:$PATH
If you want to permanently add Lua to your path, use:
1 cd ~ 2 echo 'export PATH=/usr/local/lua-5.3/bin:$PATH' >> .bash_profile 3 source .bash_profile
Start the interpreter by writing in the Terminal:
Try some Lua expressions in the interpreter:
1 print("Hello World") 2 a = 10 3 b = 25 4 print("a + b =", a + b)
You can permanently add Lua to your system path by saving the above export line at the end of your .bash_profile file.
If you are interested in learning Lua, I would recommend reading Programming in Lua by Roberto Ierusalimschy:comments powered by Disqus