Lua--4.Lua + ToLua

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. [email protected].

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下編譯和使用

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章