SoFunction
Updated on 2025-04-07

Tutorial on Lua's development environment configuration in various operating systems

Lua development environment settings

If you are willing to set up your Lua programming language environment, you need to use the following two software on your computer, (a) a text editor, (b) a Lua interpretation, and (c) a Lua compiler.
Text Editor

This will be used to enter the program to write. Some editors include Windows Notepad, operating system Edit commands, Brief, Epsilon, Emacs, and VIM or VI.

Text editor names and versions can be found on different operating systems. For example, Notepad is available on Windows, vim or vi can be used on Windows as well as Linux or UNIX.

The editor creates a file called the source file and the source code that contains the program. The Lua program source files are usually named as the extension ".lua".

Before you start programming, make sure you have established a text editor and have enough experience writing a computer program that is saved in a file, compiled and finally executed.
Lua Interpreter

This is just a small program that you can type in Lua commands to let them execute immediately. When an error is encountered, it stops executing, which is different from executing to fully compile a Lua file.
Lua compiler

When we extend Lua to other languages/applications, we need a software development kit and a compiler that is compatible with the Lua application programming interface.
Install on Windows

Here is a separate IDE called "SciTE" developed in the Windows environment from the /p/luaforwindows/download area.

Run the IDE to download the executable file to install Lua.

Once you have an IDE, you can create and use it to build Lua code.

If you are interested in installing Lua in command line mode, you need to install MinGW or Cygwin, and then compile and install Lua in Windows.
Install on Linux

Download and build Lua, use the following command

$ wget /ftp/lua-5.2.
$ tar zxf lua-5.2.
$ cd lua-5.2.3
$ make linux test

To install on other platforms such as AIX, ANSI, BSD, Linux universal, MinGW, POSIX, solaris, replace the Linux test using the corresponding platform name.

We have a Lua program as follows

Copy the codeThe code is as follows:
print("Hello World!")

Now we can build and run a Lua file that indicates the switch to the folder containing the file using the:cd command and then use the following command.

$ lua helloWorld

We can see the output below.

Copy the codeThe code is as follows:
hello world

Install on Mac OS X

To build/test Lua on Mac OS X, use the following command

$ curl -R -O /ftp/lua-5.2.
$ tar zxf lua-5.2.
$ cd lua-5.2.3
$ make macosx test

In some cases, you may not have Xcode and command line tools installed. In this case, you cannot use the make command. Install Xcode from the Mac App Store. Then go to Xcode Preferences and switch to download and install a component called "Command Line Tools". Once this process is completed, the make command will be provided to use.

This is not mandatory, and the statement "make macosx test" is executed. Even if this command is not executed, you can still use Lua on Mac OS X

We have a Lua program as follows

Copy the codeThe code is as follows:
print("Hello World!")

Now we can build and run a Lua file that represents the command cd used in the folder containing the file, and then use the following command.

Copy the codeThe code is as follows:
$ lua helloWorld

We can see the output below.

Copy the codeThe code is as follows:
hello world

Lua IDE

As mentioned earlier, for Windows SciTE Lua IDE is the default IDE provided by the Lua creator team. Alternative IDEs are available from ZeroBrane, which can be used across multiple platforms, including Windows, Mac and Linux operating systems.

There is also an Eclipse plug-in that can also be used to develop Lua. Using an IDE makes it easier to develop, such as code completion features, and is highly recommended. The IDE also provides interactive mode programming similar to the command line version in Lua.