Compilation of Lua Lib in VC

Source: Internet
Author: User

Lua provides source code for compilation by users. You can compile it into a static library or a dynamic library. However, Lua does not provide engineering files and needs to be added by the user. This is inconvenient for new users.

I. Lua static library

Compiling to a static library is simple. Someone has already written it. The following is an excerpt:

Lua includes core lib and standard Lib. For details, refer to the document. For simplicity, we put it in a Lib. We need to createStatic LibraryProject, and then add its source file to the project, including the following files
Core Lib: lapi. c lcode. c ldebug. c. c ldump. c lfunc. c lgc. c llex. c lmem. c lobject. c lopcodes. c LP *** R. c lstate. c lstring. c ltable. c ltests. c ltm. c lundump. c LVM. c lzio. c

Standard Lib: lauxlib. c lbaselib. c ldblib. c liolib. c lmathlib. c ltablib. c
Lstrlib. c loadlib. c
And set the output path to Lib.

Ii. Lua dynamic library

To compile a dynamic library, you must first modify it.Lua. hHeader file. As follows:

/* Mark for all API functions */
// # Ifndef lua_api
// # Define lua_api extern
// # Endif
# Ifdef lua502_exports// Depends on your project
# Define lua_api _ declspec (dllexport)
# Else
# Define lua_api _ declspec (dllimport)
# Endif

Then createWin32 DLL, Including *. h and *. c files (refer to 1). Compile the file.

3. About luabind

Luabind is a package for Lua to facilitate interaction with C ++. Similarly, luabind only provides source code. Use it in VC without compiling it into a dynamic library or DLL. You only need to include the *. cpp file of luabind in the project. Luabind6 uses boost 1.30.0, so you need to perform the following operations (boost in a later version is not supported ).

In addition, luabind may cause various problems in vc6 SP5, so it is better to use a later version of VC.

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.