Vs2012 compilation and configuration lua5.2.3

Source: Internet
Author: User

As a programmer of the mobile game client, I must have encountered such a problem. The game has been submitted for release, but the next day I found a logic bug in the game. What should I do, if it is not serious, it is generally not forced to update. If it is a serious bug, force the player to update it. But the game that was just downloaded the night before will be re-downloaded the next morning! Our games are not gold bars, and players are not so patient to download for the second time. At this time, a large number of players are lost!

Especially for appstore, it takes half a month for a game to be submitted for review. If serious bugs are found in the last half month, the game company can only watch the game players lose!

At this time, the advantage of Lua is reflected. as long as several text files are updated, a bug is solved. players do not need to re-download the installation package, which also saves half a month to submit the review!

Next we will learn how to use Lua on win platform.


First, download Lua:

http://www.lua.org/download.html
As a script library, Lua is really small!

After the download is complete, decompress the package and go to the SRC folder. Here is all the code of Lua.

We need to compile these dozens of codes into lib so that we can use them on windows!

Open Vs and create an empty project.

Then add the code under the src directory to the project.

Open the Lua. c file, find the main function, and change it to lua_main ()

Open the luac. c file, find the main function, and change it to luac_main ()

Modify project attribute to lib

Then generate!

After the build is successful, find the generated lualib. Lib file in the debug folder.


Lua compiled


Next we will create a test project to test

Create an empty project, configure the header file directory, Reference Library directory, and the library to be referenced.

Header file directory: src directory after Lua Decompression

Reference Library Directory: Compile the lualib. lib directory

Reference Library: lualib. Lib


Add a file and enter the following code:

#include <stdio.h>#include<windows.h>#include "lua.h"#include "lualib.h"#include "lauxlib.h"#include "luaconf.h"int main(int argc, char* argv[]){lua_State* L = luaL_newstate();luaL_openlibs(L);luaL_dofile(L, "./test.lua");lua_close(L);system("pause");return 0;}

From the code above, we can see that a test. Lua file is opened, and we create a test. Lua file in the same level directory of the Code File above.

function show()local b = {}local indexfor index = 1,10,1 doprint(index)endendshow()

Run. If 1-10 is printed, the operation is successful!


Vs2012 compilation and configuration lua5.2.3

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