Building Lua 5.2 on OS X
Posted on January 12, 2013 by Sol
If you want to build yourself the latest Lua on OS X 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/lua-5.2.
- Build and install Lua:
1 sudo make macosx install INSTALL_TOP=/usr/lua-5.2
In order to be able to use the Lua we’ll need to add the interpreter to our system path, paste the next line in a Terminal:
1 export PATH=/usr/lua-5.2/bin:$PATH
and 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