Lua--4.Lua + ToLua
Lua--4.Lua + ToLua1 Foreword2 What is lua and tolua?3 Availability4 Compile as a static library
4.1 download lua and tolua4.2 create a Qt project4.3 copy files from lua to Qt project4.4 copy files from tolua to Qt project4.5 run Qt project in Debug / Release mode4.6 Add static library to the Main project
参考
1 Foreword
This is about how to use lua-5.2.4 and tolua-5.2.4. Contacting the author tolua has been designed and implemented by Waldemar Celes. celes@tecgraf.puc-rio.br.
2 What is lua and tolua?
Lua is a powerful, fast, and lightweight embedded scripting language. Can be used as a language to interact with C / C ++ script execution. And the entire library of Lua is very small, the Lua 5.1 version of the statically linked lua.dll is only 164KB, so Lua is very lightweight, especially suitable for lightweight script embedding.
Tolua is a tool that greatly simplifies the integration of C/C++ code with Lua. Based on a “cleaned” header file, tolua automatically generates the binding code to access C/C++ features from Lua. Using Lua API and tag method facilities, the current version automatically maps C/C++ constants, external variables, functions, namespace, classes, and methods to Lua. It also provides facilities to create Lua modules.
3 Availability
tolua is freely available; you can redistribute it and/or modify it. The software provided hereunder is on an “as is” basis, and the author has no obligation to provide maintenance, support, updates, enhancements, or modifications. tolua can be downloaded from the sites below:
https://www.lua.org/download.html
http://webserver2.tecgraf.puc-rio.br/~celes/tolua/
http://webserver2.tecgraf.puc-rio.br/~celes/tolua/tolua-3.2.html#using
4 Compile as a static library
4.1 download lua and tolua
Download lua-5.2.4 from here: https://www.lua.org/download.html.
Download tolua-5.2.5 from here: http://webserver2.tecgraf.puc-rio.br/~celes/tolua/.
4.2 create a Qt project
New Project -> Library -> C++ Library -> choose static library
4.3 copy files from lua to Qt project
copy all the files but Makefile from lua-5.2.4/src to Qt project.
4.4 copy files from tolua to Qt project
copy the follow files from tolua-5.2.4 to Qt project.
? tolua-5.2.4/include/tolua.h
? tolua-5.2.4/src/lib/* but Makefile
4.5 run Qt project in Debug / Release mode
you will get .a file in Debug / Release mode
4.6 Add static library to the Main project
the file outlook like this:
? /tolualib/include/
lua.h、luaconf.h、lualib.h、lauxlib.h、tolua.h
? /tolualib/lib/xxx.a (debug / release)
参考
1、lua官方–lua-5.2.4
2、tolua-5.2.5
3、(使用lua++)Lua脚本和C++交互(三)
4、Win32下 Qt与Lua交互使用:配置Qt下Lua运行环境
5、记录一下Lua在Qt下编译和使用
页:
[1]