c++ Lua binding

本文探讨了C++与Lua脚本语言之间的交互方法,包括从Lua调用C++定义的方法,以及在C++中运行Lua脚本。通过tolua等解决方案,实现了无需重新编译C++即可提供高级抽象的解决方式。文章还详细介绍了在VS中编译DLL和使用DEF文件的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

C++ Lua binding

功能:从Lua中调用C++定义的方法,在c++中跑Lua脚本
情景:提供高级,抽象的解决方法,无需c++重新编译。

实现原理

C中调用Lua。 一个CAPI和栈实现。
仔细的解释可以看blog
Lua中调用C
C中函数导出动态链接库
Lua运行时候require需要加载动态库
关于如何在vs中编译dll 和 def使用说明
lua调用c++dll 简单案例
windows写一个dll

tolua-accessing c/c++ code from Lua

tolua 是一种解决方案。
可以看使用 tolua 实现 lua 与 c++ 交互
zeus中也是使用这个方法的。注册函数给lua使用,同时也在cpp中call dofile方法

extern “C”

What extern “C” does is affect linkage. C++ functions, when compiled, have their names mangled – this is what makes overloading possible. The function name gets modified based on the types and number of parameters, so that two functions with the same name will have different symbol names.

kaguya

laguya

header-file only
seamless access to lua elements

资源

Lua系统

todo

cmake的组织方法

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值