user6027203
user6027203

Reputation:

How to resolve missing Lua DLL when using LuaBinaries and LuaBridge?

I'm trying to embed Lua into C++ (and learn Lua), starting off with Elias Daler's training wheels method here. I'm using MSVC 14.0, LuaBinaries 5.3.2 - Release 1 (specifically, lua-5.3.2_Win32_dllw4_lib.zip here), and LuaBridge 2.0.

I've added the following Additional Include Directories:

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

And the following Additional Dependency:

C:\lua-5.3.2_Win32_dllw4_lib\liblua53.a

And I'm using the following source (pared down as far as it can):

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

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

That source compiles and links fine, but the application itself causes a standard missing DLL system error:

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

lua53.dll is in C:\lua-5.3.2_Win32_dllw4_lib\ —what am I missing?

Upvotes: 1

Views: 1368

Answers (1)

Binary Birch Tree
Binary Birch Tree

Reputation: 15728

According to the official Microsoft documentation, Windows searches for DLLs in the following directories:

  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.

So, one way to solve the problem would be to add C:\lua-5.3.2_Win32_dllw4_lib to the current user's PATH.

Compared to the other options, this has the advantages of not requiring admin privileges and not requiring lua53.dll to be in either the current directory or the same directory as your executable.

Upvotes: 1

Related Questions