Configure the LUA development environment in VS.net

Source: Internet
Author: User

InVS.netConfiguringLUA Development EnvironmentIs the content to be introduced in this article, mainly to understandLUALUA development environment.VS.netHow to configureDevelopment Environment.

Download the Lua source code from the official homepage www.lua.org. The latest version is 5.1.2. After decompression, find the "src" folder, Which is Lua, but cannot be used directly. Use any ansi c compiler and use VS2005 to compileLUA. The procedure is as follows:

1. Create an empty Console project. The project name is "lua"

2. Copy all the files in src to the project folder.

3. Add the file to be compiled based on the generated file

4. Use the Release configuration for compilation

The following is a detailed description of various types of file generation:

Dynamic library compilation defines def files or

First, modify the Lua. h header file. As follows:

 
 
  1. /* Mark for all API functions */
  2. // # Ifndef LUA_API
  3. // # Define LUA_API extern
  4. // # Endif
  5. # Ifdef LUA502_EXPORTS // depends on your project
  6. # Define LUA_API _ declspec (dllexport)
  7. # Else
  8. # Define LUA_API _ declspec (dllimport)
  9. # Endif
  10. Then, use vc to create a win32 dll, which contains *. h and *. c files. Refer to 1). compile it.

Static library file lua. lib

1. Add all files except "lua. c" and "luac. c" to the Project

2. Change [project properties]-> [configuration properties]-> [general]-> [project type] To "static library file (. lib )"

Interpreter lua.exe

1. Add all files except luac. c to the Project

2. Change [project properties] In the Release status-> [configuration properties]-> [general]-> Configure project attributes as Release application (.exe )"

Editor luac.exe

3.1 add all files except "lua. c" to the Project

3.2. Change [project properties]-> [configuration properties]-> [general]-> Configure project attributes as Release application (.exe) "in the Release state )"

Note: The name of the file is lua.exe, because the project name is "lua ". If the interpreter lua.exe is generated before, the interpreter should be removed and then generated.

2. Use LUA

Use the static library lua. lib

1. Create an empty console project and add an empty source file.

2. Add the following code to the file and modify the path.

 
 
  1. //  
  2. //                      Lua Test Object  
  3. //                      C++ Source lua_test.cpp  
  4. //  
  5. //  
  6. //                      Include Files  
  7. //  
  8. extern "C"  
  9. {  
  10. #include "D:\\My Documents\\Visual Studio 2005\\Projects\\lua\\lua\\lua.h"  
  11. #include "D:\\My Documents\\Visual Studio 2005\\Projects\\lua\\lua\\lualib.h"  
  12. #include "D:\\My Documents\\Visual Studio 2005\\Projects\\lua\\lua\\lauxlib.h"  
  13. }  
  14. //  
  15. //                      Libraries  
  16. //  
  17. #pragma comment( lib ,"D:\\My Documents\\Visual Studio 2005\\Projects\\lua\\release\\lua.lib")  
  18. //  
  19. //                      Main Functions  
  20. //  
  21. int main( void)  
  22. {  
  23.   return 1;  

3. If the compilation succeeds, the lua. lib file of the static library is successfully configured.

Use the interpreter lua.exe

1. Set system environment variables

My computer-> properties-> advanced-> environment variable (N)-> system variable-> Path-> Add the Path of zookeeper lua.exe at the end, for example:

D: \ My Documents ents \ Visual Studio 2005 \ Projects \ lua \ release, restart the machine.

2. Create a text file, enter print ("Hello World"), and change the file name to a. lua.

3. Enter lua a. lua in CMD.

4. If the character string Hellow worldappears, the interpreter lua.exe is configured successfully.

Use the compiler luac.exe

1. Set system environment variables

My computer-> properties-> advanced-> environment variable (N)-> system variable-> Path-> Add the Path of zookeeper lua.exe at the end, for example:

D: \ My Documents ents \ Visual Studio 2005 \ Projects \ lua \ release, restart the machine.

2. Create a text file, input print ("Hello World"), and exit. Change the file name to a. lua. You can directly use the previous a. lua file)

3. Enter luac a. lua in CMD.

4. If the luac.outfile is displayed in the directory a.lua.pdf, the interpreter luac.exe is configured successfully.

Summary: InVS.netConfiguringLUA Development EnvironmentI 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.