About · Installation · Change · License · Reference Manual · Chinese-English terminology glossary
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.
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.
On most Unix-like platforms, type "make" plus an appropriate platform name. The steps 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.
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" 。
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.
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.
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.
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:
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.
Here are the main changes introduced in Lua 5.3:Reference Manuallisted inIncompatibilities。
ipairsand the table library will also take metamethods into accountstring.dumpadded more trimming optionstable.move
string.pack
string.unpack
string.packsize
lua_gettableas well as the value types of results returned by similar functionslua_dumpadded trimming optionslua_geti
lua_seti
lua_isyieldable
lua_numbertointeger
lua_rotate
lua_stringtonumber
argTables are available to all codeLua 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.