我们使用 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"
}
Run Code Online (Sandbox Code Playgroud)
同一个项目在 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)
等等。