c++ - 使用 LuaBinaries 和 LuaBridge 时如何解决丢失的 Lua DLL?

标签 c++ dll lua luabridge

我正在尝试将 Lua 嵌入到 C++ 中(并学习 Lua),从 Elias Daler 的训练轮方法开始 here .我正在使用 MSVC 14.0、LuaBinaries 5.3.2 - Release 1(具体来说,lua-5.3.2_Win32_dllw4_lib.zip here)和 LuaBridge 2.0。

我添加了以下附加包含目录:

C:\lua-5.3.2_Win32_dllw4_lib\include;C:\LuaBridge

以及以下附加依赖项:

C:\lua-5.3.2_Win32_dllw4_lib\liblua53.a

我正在使用以下来源(尽可能精简):

#include "stdafx.h"
#include <LuaBridge.h>

int main() {
    luabridge::lua_State* L = luabridge::luaL_newstate();
}

该源代码可以正常编译和链接,但应用程序本身会导致标准的缺少 DLL 系统错误:

The program can't start because lua53.dll is missing from your computer. Try reinstalling the program to fix this problem.

lua53.dll 在 C:\lua-5.3.2_Win32_dllw4_lib\— 我错过了什么?

最佳答案

根据official Microsoft documentation , Windows 在以下目录中搜索 DLL:

  1. The directory where the executable module for the current process is located.

  2. The current directory.

  3. The Windows system directory. The GetSystemDirectory function retrieves the path of this directory.

  4. The Windows directory. The GetWindowsDirectory function retrieves the path of this directory.

  5. The directories listed in the PATH environment variable.

因此,解决该问题的一种方法是将 C:\lua-5.3.2_Win32_dllw4_lib 添加到当前用户的 PATH

与其他选项相比,这具有不需要管理员权限和不需要 lua53.dll 位于当前目录或与您的可执行文件相同的目录的优点。

关于c++ - 使用 LuaBinaries 和 LuaBridge 时如何解决丢失的 Lua DLL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37352199/

相关文章:

dll - 如何包含 opencv dll 以便 exe 运行

excel - 如何确定 Excel UDF 来自哪个 DLL?

Lua gsub 第二个实例

c# - 如何在 .NET 中验证 DLL 的数字签名

lua - `table.insert` 如何处理 Lua 中的自定义表

types - 类型检查不适用于 Luau 中的通用字符串键?

c++ - 没有重载函数 getline c++ 的实例

c++ - 命令行输入c++

c++ - MIC.o 文件链接错误

c++ - 抽象工厂改进