The Mac platform compiles and installs the LUA runtime environment and Hello Lua instance _lua

Source: Internet
Author: User
Tags lua

1, download the LUA installation package

Download Address: http://www.lua.org/download.html, the newest LUA is currently 5.2.3. Decompression to get doc, SRC, Makefile, readme a total of 4 files.

2. Compiling the LUA environment

1 below the console CD Lua decompression path.
2 Execute make platform, I am a Mac, so execute make macosx;
3 Generate LUA and Luac two executables in SRC, these two files can be taken out separately, such as we create the bin directory under the LUA decompression path, and put the resulting executable file in.

3, Hello Lua

1) Direct output of the console:

(1) Execute:./lua in the LUA executable directory that was just generated, into the LUA environment.
(2) Input: Print ("Hello lua") Enter, you can play Hello Lua, successful. Control+d Exit current LUA Interactive command

2 Compile output through file:

(1) Implementation: Nano Hello.lua;
(2) Enter: Print ("Hello Lua"), and then execute Control+x;y;control M sequentially. At this point, Hello.lua is saved to the directory of the LUA executable file.
(3) Execute./lua hello.lua to print hello Lua.
(4) can also be compiled and executed:./luac Hello.lua. At this point, the luac.out is generated in the Hello.lua directory, and/lua luac.out is executed. You can also print Hello Lua.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.