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.