我们使用 Lua (www.lua.org) 脚本让用户自定义我们用 C++ 编写的服务器软件。

目前,我们正在将项目的 32 位 Windows 版本移植到 Visual Studio 2010。
一旦 VS 2008 一切正常,我们认为升级过程不会有问题。

不幸的是,每当我们尝试在 VS 2010 中将 lualib(作为 dll)链接到我们的项目时,链接器都找不到 lua 函数(错误消息如下所示)。

似乎某些调用约定在 2010 年是错误的,例如应用程序可能正在寻找带有前缀“_”的 lua 函数。

要从我们的项目模块 (C++) 访问 lua 函数(用 C 编写),我们使用:

extern "C" {
#include "lua/src/lua.h"
#include "lua/src/lualib.h"
#include "lua/src/lauxlib.h"
}

同一个项目在 VS 2008 和 Linux (g++) 上成功编译并与 lualib 链接。

有人可以帮我解决这个问题吗?

1>dscscript.obj : error LNK2019: 函数“public: int __thiscall DsCScriptEngine::Init(void)”中引用的未解析的外部符号__imp__luaL_openlibs (?Init@DsCScriptEngine@@QAEHXZ)

1>dscscript.obj : error LNK2019: 函数“public: int __thiscall DsCScriptEngine::Init(void)”中引用的未解析的外部符号__imp__luaL_newstate (?Init@DsCScriptEngine@@QAEHXZ)

1>dscscript.obj : error LNK2019: 函数“public: void __thiscall DsCScriptEngine::Shutdown(void)”中引用的未解析的外部符号__imp__lua_close (?Shutdown@DsCScriptEngine@@QAEXXZ)

1>dscscript.obj : error LNK2019: 函数“public: long __thiscall DsCScriptEngine::Execute(char const *)”中引用的未解析的外部符号__imp__lua_pcall (?Execute@DsCScriptEngine@@QAEJPBD@Z)

等等。

最佳答案

报告的缺失名称是正确的,这不是编译问题。您一定是链接了错误的 .lib。你用的名字听起来不对,不是“lualib”,当前版本的导入库叫lua5.1.lib(或者lua51.lib,不知道有什么区别)。下载 from here

关于c++ - 将 Lua 与 Visual Studio 2010 联系起来,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/3843275/

10-12 06:13