我在尝试构建我的项目时收到错误 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!