MAC 上搭建lua环境

一、下载并安装

(1)最新release版下载地址

http://www.lua.org/ftp/lua-5.3.1.tar.gz

(2)编译

Building

Lua is implemented in pure ANSI C and compiles unmodified in all platforms that have an ANSI C compiler. Lua also compiles cleanly as C++.

Lua is very easy to build and install. There are detailed instructions in the package but here is a simple terminal session that downloads the current release of Lua and builds it in Linux:

curl -R -O http://www.lua.org/ftp/lua-5.3.1.tar.gz
tar zxf lua-5.3..tar.gz
cd lua-5.3.
make linux test

For Mac OS X, use make macosx test.

正常情况下会出现: src/lua -v

(3)安装

然后再输入“sudo make install”命令,会要求输入Password:     输入相应密码(你的密码),然后回车就自动安装了
待安装完成后可输入 lua -v,回车就会看到 :
Lua 5.3.1  Copyright (C) 1994-2015 Lua.org, PUC-Rio
OK ,已经安装成功!

二、使用IDE

1. 安装Sublime

2. 安装Lua编译器

Tools->Build System->New Build System

输入:

{
"cmd": ["/usr/local/bin/lua", "$file"],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.lua"
}

保存为Lua.sublime-build,然后Tools-Build System上就能选择lua来编译脚本了。

3. 使用Sublime编写Lua代码

lua的编辑和运行环境已经搭建好了
新建一个hello.lua文件,随便写个语句,选择lua为build system,按一下Command+B,就能跑出来了。
MAC 上搭建lua环境
 
上一篇:ACM/ICPC 之 DFS求解欧拉回路+打表(POJ1392)


下一篇:JavaScript实现字符串的contains函数