Detailed description of LUA development tool and its environment Configuration

Source: Internet
Author: User

LUA Development ToolAnd its environment configuration is the content to be introduced in this article, mainly to understand and learnLua Development ToolFirst contact with the Environment ConfigurationLUAThen, study with me. You can't be fooled.

LUA is a language, so there must be a programming tool. For the first time, use LFWlua for windows ). I believe that your computer system is Windows.

It includes:

  1. Lua InterpreterLua Interpreter)
  2. Lua Reference ManualLua Reference manual)
  3. Quick Lua Tour Lua Quick Start)
  4. Examples Lua example)
  5. Libraries with documentation some Lua Libraries and documents)
  6. SciTE is a great multi-purpose editor that has made special settings for Lua)

Where to download? This has:

Now it seems that there are 20 + M, but it is still very small. After downloading, how can I install it directly? Where can I install it? You don't need to ask such questions ).

InstallSelect "Create a shortcut icon on the desktop ". This wayInstallOn the desktop, there are shortcut icons for LUA and SciTE. Of course, it can also be found in your installation folder.

Next, we can test whether the installation is successful.

Open SciTE, create a new file, and enter a line of lua code:

  1. print("hello,lua") 

Save as hello. lua. Note that the file name suffix. lua must be added when saving the file; otherwise, the file may not run correctly.

Press F5. If the output window of SciTE appears

  1. >lua -e "io.stdout:setvbuf 'no'" "hello.lua"   
  2. hello,lua  
  3. >Exit code: 0 

Indicates the entireLuaThe development environment is successfully installed. If the output window is not output, please let me know.

The above isLUADevelopment environment.

If you are a C/C ++ programmer, VS is used. I use VS2008. It's a bit nostalgic!

Select "Tools)" --> "Options)" --> "Projects and Solutions" --> "VC ++ DirectoriesC ++ directory )".

1) Select "Include Files" from the drop-down menu "Show Directories for display directory" on the right, and then add a new path "C: \ Program Files \ lua \ 5.1 \ include ".

2) Select "Library Files include Files" from the drop-down menu "Show Directories for display directory" on the right, and then add a new path "C: \ Program Files \ lua \ 5.1 \ lib ".

Ps: "C: \ Program Files \ lua \ 5.1 \ include" and "C: \ Program Files \ lua \ 5.1 \ lib" are the path for installing lua, you have to find your own.

OK. The configuration of VS is complete.

Let's try our first LUA application. C ++ is used)

1. Create a new blank Win32 console application project.

2. Add "luatest. cpp" to your project.

3. Select the properties menu in the project menu.

4. Enter "lua5.1.lib" in "add dependencies" in "input" of "connector ".

5. Complete.

How to compile luatest. cpp? As follows:

  1. //
  2. # Include <stdio. h>
  4. Extern "C "{
  5. # Include "lua. h"
  6. # Include "lualib. h"
  7. # Include "lauxlib. h"
  8. }/* Because it is C ++, C does not need to be added to the above fields */
  10. /* Lua interpreter pointer */
  11. Lua_State * L;
  13. Int main (int argc, char * argv [])
  14. {
  15. /* Initialize Lua */
  16. L = lua_open ();
  18. /* Load the basic Lua database */
  19. LuaL_openlibs (L );
  21. /* Run the script */
  22. LuaL_dofile (L, "absolute path of test. lua ");
  24. /* Clear Lua */
  25. Lua_close (L );
  27. /* Pause */
  28. Printf ("Press enter to exit... ");
  30. Getchar ();
  31. Return 0;
  32. }

The following is the content of test. lua. I have taught you how to write it.

  1. simple test  
  2. print ("Hello, World!") 

Summary: DetailsLUA Development ToolThe configuration of the environment is complete. I hope this article will help you!

Related Article

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: 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.