热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

InstallingLuainMac

Luaisdistributedinsourceform.Youneedtobuilditbeforeusingit.BuildingLuashouldbestraightfo

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.  


推荐阅读
  • SvpplyTable: 实现可扩展和可折叠的菜单动画
    SvpplyTable 是一个示例项目,旨在实现类似 Svpply 应用程序中的可扩展和可折叠的菜单动画效果。该项目托管在 GitHub 上,地址为 https://github.com/liuminqian/SvpplyTable。 ... [详细]
  • iOS snow animation
    CTSnowAnimationView.hCTMyCtripCreatedbyalexon1614.Copyright©2016年ctrip.Allrightsreserved.# ... [详细]
  • packagecom.panchan.tsmese.utils;importjava.lang.reflect.ParameterizedType;importjava.lang. ... [详细]
  • 蒜头君的倒水问题(矩阵快速幂优化)
    蒜头君将两杯热水分别倒入两个杯子中,每杯水的初始量分别为a毫升和b毫升。为了使水冷却,蒜头君采用了一种特殊的方式,即每次将第一杯中的x%的水倒入第二杯,同时将第二杯中的y%的水倒入第一杯。这种操作会重复进行k次,最终求出两杯水中各自的水量。 ... [详细]
  • 使用 Git Rebase -i 合并多个提交
    在开发过程中,频繁的小改动往往会生成多个提交记录。为了保持代码仓库的整洁,我们可以使用 git rebase -i 命令将多个提交合并成一个。 ... [详细]
  • 年前,我发表了一篇文章,分享了自己通过在线教育平台学习IT技能的经历。文中详细探讨了在线教育与传统线下教育在技能培训方面的优缺点。许多网友在讨论在线教育时,常常提到“在线教育是否缺乏学习氛围”的问题。本文将对此进行深入分析。 ... [详细]
  • 从零开始编译Linux系统:第16章 全新起点
    本章将详细介绍如何从零开始编译一套完整的Linux系统,涵盖关键组件如glibc库的介绍及其重要性。通过本文,读者将了解从源代码构建Linux系统的全过程。 ... [详细]
  • 阿里云 Aliplayer高级功能介绍(八):安全播放
    如何保障视频内容的安全,不被盗链、非法下载和传播,阿里云视频点播已经有一套完善的机 ... [详细]
  • JavaSE For循环入门示例
    本文将介绍Java中For循环的基本概念和使用方法,通过几个简单的示例帮助初学者更好地理解和掌握For循环。 ... [详细]
  • 本文介绍了 Go 语言中的高性能、可扩展、轻量级 Web 框架 Echo。Echo 框架简单易用,仅需几行代码即可启动一个高性能 HTTP 服务。 ... [详细]
  • Bootstrap 缩略图展示示例
    本文将展示如何使用 Bootstrap 实现缩略图效果,并提供详细的代码示例。 ... [详细]
  • 本文介绍了一种支付平台异步风控系统的架构模型,旨在为开发类似系统的工程师提供参考。 ... [详细]
  • 本文详细介绍了 com.apollographql.apollo.api.internal.Optional 类中的 orNull() 方法,并提供了多个实际代码示例,帮助开发者更好地理解和使用该方法。 ... [详细]
  • Manacher算法详解:寻找最长回文子串
    本文将详细介绍Manacher算法,该算法用于高效地找到字符串中的最长回文子串。通过在字符间插入特殊符号,Manacher算法能够同时处理奇数和偶数长度的回文子串问题。 ... [详细]
  • malloc 是 C 语言中的一个标准库函数,全称为 memory allocation,即动态内存分配。它用于在程序运行时申请一块指定大小的连续内存区域,并返回该区域的起始地址。当无法预先确定内存的具体位置时,可以通过 malloc 动态分配内存。 ... [详细]
author-avatar
je荒也是种美
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有