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:
- Lua interpreter (Lua interpreter)
- Lua Reference Manual (LUA reference manual)
- Quick Lua Tour (LUA Quick Start)
- Examples (LUA example)
- Libraries with documentation (some Lua libraries and documents)
- 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:
- 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
- >lua -e "io.stdout:setvbuf 'no'" "hello.lua"
- hello,lua
- >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:
- //
- # Include<Stdio. h>
-
- Extern "C "{
- # Include "Lua. H"
- # Include "lualib. H"
- # Include "lauxlib. H"
- }/* Because it is C ++, C does not need to be added to the above fields */
-
- /* Lua interpreter pointer */
- Lua_state * l;
-
- Int main (INT argc, char * argv [])
- {
- /* Initialize Lua */
- L = lua_open ();
-
- /* Load the basic Lua database */
- Lual_openlibs (L );
-
- /* Run the script */
- Lual_dofile (L, "absolute path of test. Lua ");
-
- /* Clear Lua */
- Lua_close (L );
-
- /* Pause */
- Printf ("press enter to exit... ");
-
- Getchar ();
- Return 0;
- }
The following is the content of test. Lua. I have taught you how to write it.
- simple test
- print ("Hello, World!")
Summary: DetailsLua Development ToolThe configuration of the environment is complete. I hope this article will help you!