Installing Lua in Mac

时间:2021-08-19 14:25:13

Lua is distributed in source form. You need to build it before using it. Building Lua should be straightforward because Lua is implemented in pure ANSI C and compiles unmodified in all known platforms that have an ANSI C compiler. Lua also compiles unmodified as C++. The instructions given below for building Lua are for Unix-like platforms. See also instructions for other systems and customization options.

If you don't have the time or the inclination to compile Lua yourself, get a binary from LuaBinaries. Try also Lua for Windows, an easy-to-use distribution of Lua that includes many useful libraries.

Building Lua

In most Unix-like platforms, simply do "make" with a suitable target. Here are the details.

  1. Open a terminal window and move to the top-level directory, which is named lua-5.2.3. The Makefile there controls both the build process and the installation process.
  2. Do "make" and see if your platform is listed. The platforms currently supported are:

    aix ansi bsd freebsd generic linux macosx mingw posix solaris

    If your platform is listed, just do "make xxx", where xxx is your platform name.

    If your platform is not listed, try the closest one or posix, generic, ansi, in this order.

  3. The compilation takes only a few moments and produces three files in the src directory: lua (the interpreter), luac (the compiler), and liblua.a (the library).
  4. To check that Lua has been built correctly, do "make test" after building Lua. This will run the interpreter and print its version string.

If you're running Linux and get compilation errors, make sure you have installed the readline development package. If you get link errors after that, then try "make linux MYLIBS=-ltermcap".

Installing Lua

Once you have built Lua, you may want to install it in an official place in your system. In this case, do "make install". The official place and the way to install files are defined in the Makefile. You'll probably need the right permissions to install files.

To build and install Lua in one step, do "make xxx install", where xxx is your platform name.

To install Lua locally, do "make local". This will create a directory install with subdirectories bin, include, lib, man, and install Lua as listed below. To install Lua locally, but in some other directory, do "make install INSTALL_TOP=xxx", where xxx is your chosen directory.

bin:
lua luac
include:
lua.h luaconf.h lualib.h lauxlib.h lua.hpp
lib:
liblua.a
man/man1:
lua.1 luac.1

These are the only directories you need for development. If you only want to run Lua programs, you only need the files in bin and man. The files in include and lib are needed for embedding Lua in C or C++ programs.

Customization

Three kinds of things can be customized by editing a file:

  • Where and how to install Lua — edit Makefile.
  • How to build Lua — edit src/Makefile.
  • Lua features — edit src/luaconf.h.

You don't actually need to edit the Makefiles because you may set the relevant variables in the command line when invoking make. Nevertheless, it's probably best to edit and save the Makefiles to record the changes you need.

On the other hand, if you need to customize some Lua features, you'll need to edit src/luaconf.h before building and installing Lua. The edited file will be the one installed, and it will be used by any Lua clients that you build, to ensure consistency. Further customization is available to experts by editing the Lua sources.

We strongly recommend that you enable dynamic loading in src/luaconf.h. This is done automatically for all platforms listed above that have this feature and also for Windows.

Building Lua on other systems

If you're not using the usual Unix tools, then the instructions for building Lua depend on the compiler you use. You'll need to create projects (or whatever your compiler uses) for building the library, the interpreter, and the compiler, as follows:

library:
lapi.c lcode.c lctype.c ldebug.c ldo.c ldump.c lfunc.c lgc.c llex.c lmem.c lobject.c lopcodes.c lparser.c lstate.c lstring.c ltable.c ltm.c lundump.c lvm.c lzio.c lauxlib.c lbaselib.c lbitlib.c lcorolib.c ldblib.c liolib.c lmathlib.c loslib.c lstrlib.c ltablib.c loadlib.c linit.c
interpreter:
library, lua.c
compiler:
library, luac.c

To use Lua as a library in your own programs you'll need to know how to create and use libraries with your compiler. Moreover, to dynamically load C libraries for Lua you'll need to know how to create dynamic libraries and you'll need to make sure that the Lua API functions are accessible to those dynamic libraries — but don't link the Lua library into each dynamic library. For Unix, we recommend that the Lua library be linked statically into the host program and its symbols exported for dynamic linking; src/Makefile does this for the Lua interpreter. For Windows, we recommend that the Lua library be a DLL.

As mentioned above, you may edit src/luaconf.h to customize some features before building Lua.

Installing Lua in Mac的更多相关文章

  1. Installing Hadoop on Mac OSX Yosemite Tutorial Part 1.

    Installing Hadoop on Mac OSX Yosemite Tutorial Part 1. September 23, 2014 Marek 68 Comments Install ...

  2. Cocos2d-x lua游戏开发之安装Lua到mac系统

    注意:mac ox .lua version :5.15 下载lua官网的lua, 注意:最好是5.15下面.5.2的lua不支持table的getn()方法,这让我情何以堪.(获取table长度.相 ...

  3. 如何在Mac OS X 中运行Lua (Running Lua on Mac OS X)

    参考文章:1) http://www.oschina.net/question/12_769552) http://rudamoura.com/luaonmacosx.html 最近在为iOS开发游戏 ...

  4. Lua for Mac环境搭建

    1⃣️在Mac上安装Lua的运行环境再简单不过了,如果你的Mac Terminal上安装了Homebrew的话,只需要键入`brew install lua`即可. longsl-mac:~ long ...

  5. Installing XGBoost on Mac OSX

      0. Get gcc with open mp.  Just paste and execute the following command in your terminal, once Home ...

  6. Mac 下纯lua(一)

    Lua 介绍 什么是lua - lua是一种跨平台开发脚本语言. Lua 历史 学校 University of Rio de Janeiro 国家 巴西 作者 Roberto Ierusalimsc ...

  7. 转载 ----MAC 上搭建lua

    MAC 上搭建lua   其实mac上搭建lua环境,google上大把资料,我只是整合一下,因为小弟搭建的时候确实碰到一些问题. 下载和安装lua:(转自这里) 1.  下载最新版的lua-5.2. ...

  8. Mac配置一些开发环境(随时补充)

    Mac安装mysql并启动 brew install mysql mysql.server start /usr/local/Cellar/mysql/5.6.10/support-files/mys ...

  9. mac下使用glew库,方法

    mac下使用glew库,方法 分类: OpenGL2015-01-15 15:52 210人阅读 评论(0) 收藏 举报   目录(?)[+]   主要参考http://www.cnblogs.com ...

随机推荐

  1. Context的使用(转)

    1.Context概念 Context,相信不管是第一天开发Android,还是开发Android的各种老鸟,对于Context的使用一定不陌生~~你在加载资源.启动一个新的Activity.获取系统 ...

  2. UVA 10557 XYZZY

    Problem D: XYZZY ADVENT: /ad�vent/, n. The prototypical computer adventure game, first designed by W ...

  3. 字符数组什么时候要加‘\0’

    当字符数组以单个字符进行赋值时: char ch[10]; ch[10]={'a','b',---'\0'}; 或者用for循环进行赋值时: for (i=0; i<9; i++){ch[i]= ...

  4. JDK源码学习系列03----StringBuffer&plus;StringBuilder

                         JDK源码学习系列03----StringBuffer+StringBuilder 由于前面学习了StringBuffer和StringBuilder的父类A ...

  5. DEDECMS点击主栏目默认显示第一个子栏目列表的方法

    本文实例讲述了DEDECMS点击主栏目默认显示第一个子栏目列表的方法.分享给大家供大家参考.具体分析如下: 今天公司有个需求是,点击导航上的父栏目进去默认显示第一个子栏目的列表,以下是具体实现方法,可 ...

  6. Win8无法访问xp共享的解决方法——win8网上邻居访问别的xp电脑要用户名和密码取消方法

    新装win8,原来的win7正常连接xp下载机的共享,但在win8下进网上邻居却无法访问xp的共享,显示”用户名或密码不正确”,而密码明明是对的如图所示: 解决方法: 按Win+R启动运行,输secp ...

  7. FreeRadius&plus;GoogleAuthenticator实现linux动态口令认证

    简介 在运维管理中,服务器的密码管理十分重要.服务器数量少的时候还好说,可以定时来改密码.一旦数量多了,再来改密码就不现实了. 前提 我们假定运维访问服务器是这样的: 创建一个普通用户用于登录服务器, ...

  8. eclipse编写js代码没有提示

    安装插件 点击Help,选择Eclipse Marketplace... 搜索js,安装AngularJS Eclipse 重启eclipse,右键项目,选择Configure(配置),选择Conve ...

  9. 在开发框架中使用FTP辅助类上传或者下载文件,方便管理附件内容

    在有些系统应用里面,我们需要对应用服务器.数据库服务器.文件服务器进行分开,文件路径等信息存储在数据库服务器里面,但文件内容则存储在文件服务器里面,通过使用FTP进行文件的上传下载,从而实现更加高效的 ...

  10. SpringBoot &plus; Security实现权限控制

    网上找了好几个,因为各种原因不太行,下面这个亲测可行 参考:https://blog.csdn.net/u012702547/article/details/54319508 基于SpringBoot ...