Welcome to Lua 5.3

About · Installation · Change · License · Reference Manual · Chinese-English terminology glossary

About Lua

Lua is a powerful, fast, lightweight embeddable scripting language. It was created by the Pontifical Catholic University of Rio de Janeiro in Brazil,PUC-Rio Teamdevelopment. Lua is aFree softwareand is widely used in countless products and projects around the world.

Lua'sOfficial websiteprovides complete information about Lua, includingComprehensive summaryand the latestDocumentation, note thatReference ManualMay be related toThe version hereThere are differences.

Install Lua

Lua usesSource codeis distributed in source form; you need to build it before using it. Building Lua is very simple, because Lua is implemented in pure ANSI C and can be compiled directly on all platforms that have an ANSI C compiler. Lua can also be compiled directly as C++. The build process on Unix-like platforms is described below. There is alsoIntroduction to other system buildsandConfiguration optionsfor reference.

If you do not have the time or interest to compile Lua yourself, you can getLuaBinariescompiled binaries fromLuaDistor get a multi-platform distribution of Lua (batteries included) here.

Building Lua

On most Unix-like platforms, type "make" plus an appropriate platform name. The steps are:

  1. Open a console window and switch tolua-5.3.0directory. Under the directoryMakefileThe file contains the build and installation process.

  2. Run "make" and check whether your platform is listed. Currently supported platforms are:

    aix bsd c89 freebsd generic linux macosx mingw posix solaris

    If your platform is among them, run "make xxx" is enough, where xxx represents your platform name.

    If your platform is not among them, first try the most similar platform, then try in the order posix, generic, c89.

  3. The compilation process is very short, and finally insrcthe directory, three files are generated: lua (interpreter), luac (compiler), and liblua.a (static library).

  4. After the build is complete, you can run "make testto check whether it was successful. It will run the interpreter and print the version number.

If you are on Linux and get compilation errors, make sure you have installedreadline(also may be calledlibreadline-devorreadline-devel) development package. After that, if there are still link errors, try "make linux MYLIBS=-ltermcap" 。

Installing Lua

Once you have built Lua, you may want to install it in the system default location, so run "make install" and that's it. The system default location and how to install are defined inMakefilein. This process may require relevant permissions.

Run "make xxx install" can build and install in one step, where xxx refers to your platform name.

If you want to install Lua locally, run "make local. It will create ainstalldirectory, containingbin, include, lib, man, share, subdirectory, and install the following files in it.make install INSTALL_TOP=xxx, xxx refers to the directory you choose.srcAnddocproceed in the directory, so whenINSTALL_TOPbe careful when it is not an absolute path.

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

These are the directories needed for development. If you merely want to run some Lua programs, then you only needbinandmanfiles under it.includeandlibThe files under are used to embed Lua into C or C++ programs.

Customization

There are three kinds of customization that can be done by editing files:

Actually you don't need to edit the Makefile; when running make, you can specify the relevant variables on the command line. Of course, editing and saving the Makefile can leave a record of the customization.

On the other hand, if you need to customize some Lua features, you need to edit before building and installing Luasrc/luaconf.h. The edited files must ensure consistency, that is, they are installed in only one place, so that all the programs you compile that use Lua use this single copy. Experts can customize more by editing the Lua source code.

Building Lua on other systems

If you do not use the standard Unix tools, then the process of building Lua depends on the compiler you use. You need to create several projects to build the library, the interpreter, and the compiler, etc. Please add the following source files to the relevant projects:

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 lutf8lib.c loadlib.c linit.c
Interpreter:
library, lua.c
Compiler:
library, luac.c

To use Lua as a library in your program, you need to know how to create libraries and use libraries with your compiler. For example, to use Lua as a dynamically loaded C library, you need to know how to create a dynamic library and make the Lua API functions visible in the dynamic library —Do notlink the Lua library into each dynamic library.src/MakefileThat is how the Lua interpreter is handled. On Windows, we recommend compiling the Lua library as a DLL. In any case, the compiler luac should be statically linked.

As mentioned above, you can edit before building Luasrc/luaconf.hto customize some features.

Changes since Lua 5.2

Here are the main changes introduced in Lua 5.3:Reference Manuallisted inIncompatibilities。

Main Changes

These are other changes introduced in Lua 5.3:

Language

library

C API

The Standalone Lua Interpreter

License

Lua is free software distributed under the terms of the MIT license reproduced below; it may be used for any purpose, including commercial purposes, at absolutely no cost without having to ask us. The only requirement is that if you do use Lua, then you should give us credit by including the appropriate copyright notice somewhere in your product or its documentation. For details, see this.

Copyright © 1994–2015 Lua.org, PUC-Rio.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


Last modified time: January 13, 2015 15:16