Install Lua in Ubuntu

Source: Internet
Author: User

Preface:

The Lua scripting language is also the first touch. the previously used scripting language only has python. After reading some introductions of Lua, I feel that this scripting language is more concise than python, although there are not so many standard libraries that can be supported by python, its flexibility and scalability make this scripting language have a foothold. Particularly in the gaming field, Lua's status is really unusual.

My system is ubuntu14.04, and the Environment is

Linux version 3.13.0-29-generic ([email protected]) (gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1) ) #53-Ubuntu SMP Wed Jun 4 21:00:20 UTC 2014

Today, I am interested in learning about Lua development, which is of great help to mobile games.

1. Build a Development Environment

Building an environment before development is essential. For Linux users, you can simply use a line of command to install Lua on the terminal. However, the installation of Lua may cause some problems for the embedding of C or C ++, some files cannot be found.

Therefore, you need to download the Lua source code on the official website and then install it.

You can find the following version information on the official website or directly enter the Lua official website.


I downloaded the version 5.1.5. After downloading the source code file, decompress it to a folder and enter the path to the extracted file from the terminal. This is the information in my folder.


The makefile folder is displayed and runs directly on the terminal.

<span style="font-size:24px;">make linux</span>

2. Problems Encountered

1) The Readline. h file cannot be found.

Some problems may occur when executing this command. The first problem is that the Readline. h file cannot be found.

error:readline/readline.h:no such file or directory 
Solution: Install apt-file, which is a software package search tool. You can find the files contained in the software package and the installation location.

Enter:

sudo apt-get install apt-file  
Then enter:

sudo apt-file update  
At this time, Apt-file is installed, and the libreadline library is installed at this time.

sudo apt-get install libreadline-dev
After libreadline is installed, run the make Linux Command to solve the problem.

2) The-lncurses file is not found.

However, another problem occurs, prompting that the file-lncurses cannot be found.

/usr/bin/ld: cannot find -lncurses
Solution

Input on the terminal

sudo apt-cache search ncurses- | grep ^libncurses
You will see information about a libncurses5-dev, as shown below


Install the libncurses5-dev directly on the terminal at this time

sudo apt-get install libncurses5-dev
The following interface indicates that the installation is complete.


At this time, execute the make Linux Command to compile the Lua file. below is the compiled information.


After compilation, you can enter

make install
Command to install Lua. The installation information is as follows:


At this time, it indicates that Lua has been installed in your system and is directly entered in the command line.

lua test/hello.lua
Test whether the installed Lua can be run.

All the work here is OK, so you can start your Lua learning journey.

For me, the main purpose of using the Lua language is to embed it into C or C ++ code to make program development or modification simpler and give full play to the scalability of the Lua language.


Install Lua in Ubuntu

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.