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. 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下编译和使用

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

worthsen

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值