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
基础教程推荐
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- CString 到 char* 2021-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 初始化列表*参数*评估顺序 2021-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
