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, lfw (LUA for Windows) is used ). I believe that your computer system isWindows.

It includes:

 
 
  1. Lua interpreter (Lua interpreter)
  2. Lua Reference Manual (LUA reference manual)
  3. Quick Lua Tour (LUA Quick Start)
  4. Examples (LUA example)
  5. Libraries with documentation (some Lua libraries and documents)
  6. Scite (a great multi-purpose editor with special settings for LUA)

Where to download? This has: http://luaforwindows.luaforge.net/

Now it seems that there are 20 + M, but it is still very small. Install the SDK directly after the download (how to 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 ++ directories (C ++ 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 (including 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>
  3. Extern "C "{
  4. # Include "Lua. H"
  5. # Include "lualib. H"
  6. # Include "lauxlib. H"
  7. }/* Because it is C ++, C does not need to be added to the above fields */
  8. /* Lua interpreter pointer */
  9. Lua_state * l;
  10. Int main (INT argc, char * argv [])
  11. {
  12. /* Initialize Lua */
  13. L = lua_open ();
  14. /* Load the basic Lua database */
  15. Lual_openlibs (L );
  16. /* Run the script */
  17. Lual_dofile (L, "absolute path of test. Lua ");
  18. /* Clear Lua */
  19. Lua_close (L );
  20. /* Pause */
  21. Printf ("press enter to exit... ");
  22. Getchar ();
  23. Return 0;
  24. }

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!

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.