Windows7 the compilation and configuration of Lua, Visual Studio2013

Source: Internet
Author: User
Tags lua

To configure LUA under Windows7
A Configuring the Environment
Operating system: Windows7 64-bit flagship edition
lua:lua5.3
Ide:visual Studio 2013

Two. Preparatory work
1. Go to Lua's official website to download the LUA source code, the latest version is 5.3,lua's official website: http://www.lua.org/, download and unzip to the directory you want.
2. Install Visual Studio 2013. Not necessarily the 2013 version, 2010 can also.
Three. Start configuration
1. Open VS2013, create a new empty solution (construction project?). Other Project types? Visual Studio Solution), the location of your choice, the solution name is called Lua_build. And then determine.

We have finished the most basic work. Next we will create a new three project in the solution. Lua_lib,lua and Luac, respectively. Each of the three projects has its own capabilities, and in the Lua and LUAC projects, we will generate the execution files that we want in the end. Lua_lib will generate static library files, and the compilation of Lua and LUAC projects requires this library file. So we first have to compile the Lua_lib project and generate the required library files.

2. Generate the required library files
On the Lua_build solution, right-click Add –> New Project –>visual C + + project –> Empty project. We named the project Lua_lib. And then determine.

Our Lua_lib project has been built. Next we will add the LUA source code to the project.
On the project, right-click –> add –> already exists. Open the directory where we unzipped the LUA. Find the SRC folder, you need to note that, in addition to LUA.C and luac.c two files, are added to the project. The Lua_lib project generates the library files we need, and LUA.C and LUAC.C are used in the LUA and LUAC projects, respectively.

After the file is added, the nature is to compile, but do not worry, we also have to configure our project properties, so that the project in our compile time to generate Lib is the library file.

On the Lua_lib project, right-–> the property –> the configuration property –> the general –> configuration type. Select the static library and then OK. Right-click the Lua_lib project and select Compile. After the run completes, VS2013 will generate a debug folder under the solution with a lua_lib.lib file, which is the library file required for the LUA and LUAC projects.

3. Generate Lua.exe and Luac.exe executables (target files)
New two projects in Lua_build solution Lua and Luac.

Add the Lua.c file to the LUA project. LUAC.C Add to Luac project

Next, do the same for both LUA and LUAC projects. The first is because they need to compile all the Lua_lib.lib library files, so the two items are mapped into the Lua_lib.lib library file. And you're going to tell Lua and Luac where to look for this library file, so you have to include the folder where the Lua_lib.lib files are in the two items.
Right-click Lua Project –> Properties –> Configuration Properties –> linker –> input –> Additional dependencies

Click the drop-down button –> edit –> fill in Lua_lib.lib (the file name is actually the same as the Lua_lib project) –> OK.

Instead of closing the Properties window just now, select General –> Additional Library directory –> Click the drop-down button –> edit –>
Click the folder button in the upper-right corner –> Add the directory of the Lua_lib.lib library files that we started to generate, and then OK.
These two steps are also carried out for the LUAC project.

4. Generate the target executable file
Right-click the solution, compile. The two executables, Lua.exe and Luac.exe, can be generated in the debug directory of the solution after success, both of which are the files we want.

Four. Test our compiled target file

We open the console and locate the directory in the Debug folder of our previous Lua_build solution.

Enter Lua.exe on the console and we'll be able to enter the LUA handler, which shows the version number, copyright, etc.

For a simple test, enter print ("Test Lua") and enter, and we see the output of test Lua. Success.
We can also run the. lua file directly. We create a new Test.lua file in the current directory, we enter print ("Test lua") in the Test.lua file;

Enter Lua.exe Test.lua in the console. And then you'll see the same output

We'll test the Luac.exe next. The Luac.exe function is somewhat similar to a compiler. It turns the. lua file into an. Out binary, which can then be executed with Lua.exe.
The Luac.out file is generated under control too Luac.exe Test.lua in the current directory. Then execute the Lua.exe luac.out and you will see the same output.

Windows7 the compilation and configuration of Lua, Visual Studio2013

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.