quot;Undefined reference toquot; using Lua(“未定义的引用使用 Lua)
问题描述
我在尝试构建我的项目时收到错误 undefined reference to 'luaL_newstate'
.我知道这是链接器的错误,但我对 Lua 比较陌生,并向项目添加了一个库.顺便说一下,我使用 Code::Blocks.API函数luaL_openlibs
、luaL_loadfile
、lua_pcall
、lua_getfield
、lua_type
、lua_settop
也不见了.
I got the error undefined reference to 'luaL_newstate'
when I try to build my project. I know it's an error with the linker but I'm relatively new to Lua and adding a library to a project. I use Code::Blocks by the way. API functions luaL_openlibs
, luaL_loadfile
, lua_pcall
, lua_getfield
, lua_type
, lua_settop
are missing too.
我在一个网站上看到我必须将我的项目与 libdl 链接才能解决这个问题,但我真的不知道这是什么意思以及如何去做.
I saw on a webite that I have to link my project with libdl in order to solve this problem, but I don't really know what it mean and how to do it.
推荐答案
我遇到了同样的问题,就我而言,我找到了一个对我有用的解决方案 此处.基本上包括将 lua 的 #include 包裹在 extern "C" 中,例如:
I faced the same problem, in my case I found a solution that worked for me here. Basically consist in wrapping the #include s of lua inside a extern "C", like:
extern "C"{
#include <lua5.2/lualib.h>
#include <lua5.2/lauxlib.h>
#include <lua5.2/lua.h>
}
这篇关于“未定义的引用"使用 Lua的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:“未定义的引用"使用 Lua


- 近似搜索的工作原理 2021-01-01
- 静态初始化顺序失败 2022-01-01
- 如何对自定义类的向量使用std::find()? 2022-11-07
- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01
- 使用/clr 时出现 LNK2022 错误 2022-01-01
- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01
- STL 中有 dereference_iterator 吗? 2022-01-01
- Stroustrup 的 Simple_window.h 2022-01-01
- C++ 协变模板 2021-01-01
- 从python回调到c++的选项 2022-11-16