“未定义的引用"指的是:使用Lua [英] "Undefined reference to" using Lua

查看:386
本文介绍了“未定义的引用"指的是:使用Lua的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试构建项目时出现错误undefined reference to 'luaL_newstate'.我知道链接器有错误,但是对于Lua来说我是比较陌生的人,并且向项目中添加了一个库.我顺便使用Code :: Blocks. API函数luaL_openlibsluaL_loadfilelua_pcalllua_getfieldlua_typelua_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.

推荐答案

我遇到了同样的问题,就我而言,我找到了一个对我有用的解决方案中,例如:

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆