在c++中使用Lua
Using Lua with C++
我正试图在c程序中嵌入lua,但我在编译代码时遇到了问题。我已经在synaptic中安装了lua 5.2相关的所有内容,当我试图编译这个时:
extern "C"{
#include <stdio.h>
#include <string.h>
#include "lua5.2/lua.h"
#include "lua5.2/lauxlib.h"
#include "lua5.2/lualib.h"
}
int main(int argc, char* argv[])
{
lua_State *lua_state;
lua_state = luaL_newstate();
lua_close(lua_state);
}
和使用
编译g++ main.cpp -llua
显示以下错误
找不到-llua
什么?
您可以使用一些工具来查找库的适当编译器/链接器开关。
特别是,在正确安装了lua5.2库之后,您可以使用
pkg-config -libs lua5.2
在我的系统上它输出
-llua5.2
使用这个,或者pkg-config的输出(反勾)作为您的链接器参数。
当然,pkg-config也可以告诉你
包的-CFLAGSpkg-config --cflags lua5.2
手册页很好读
相关文章:
- C++Lua用户数据扰乱了Mathfu浮点值
- 使用 LuaBridge 或 Lua 将对象传递给 Lua 函数C++
- 将 Lua 函数块转换为 C 字符串
- 我可以从 lua 5.0.2 加载用 c++ 编写的 lua 5.3.5 dll 吗?
- 使用 lua 协程 API 和lua_close时出现分段错误
- 使用 C++ 自动 Lua 绑定
- 调用 lua 函数的地址为 C/C++?
- lua 5.0.2 模块和 5.3.5 有什么区别?
- 如何将 Lua 添加到C++项目
- 使用 Lua 中的C++库对象
- 如何在C++中将用户数据从一个 Lua 块传递到另一个块
- 如何使用重新定义的打印函数打印Lua表?
- Lua table in C++ dll
- 在运行时环境中使用 C++ w/ Lua
- 将shared_ptr传递给Lua
- luaL_len is missing in Lua 5.1
- 将向量传递给<struct> Lua 表
- 将 Lua 与 C++ DLL 结合使用
- Lua C API - 从C++分配和使用类的对象成员
- C++中最接近 Lua 表操作的东西是什么?