I’m looking at incorporating Lua into a C++ project, and am a bit confused by the presence of the two binaries (lua51.dll and lua5.1.dll) in the distribution from Luabinaries.
According to the docs…
In Windows your library or application
must be linked with a stub library. A
stub library is a library with only
the function declarations that will
bind your DLL with the Lua DLL.
Why? I’ve never needed stub DLLs before when linking with third-party DLLs?
A stub library is a
.libfile, not a DLL. It contains function declarations for all the exported functions in the DLL, which just forward the call into the DLL itself. So if you build an application that you want to link withlua51.dll, you tell the linker to link withlua51.lib, and all calls to exported functions will be forwarded to the DLL. If you didn’t do this, you would get a lot of “unresolved external symbol” errors when linking.This is only needed when statically linking with a DLL (so that it is loaded automatically when the application is run). It is not needed when loading the DLL dynamically with
LoadLibrary.Regarding why they have two different DLLs, The manual says this:
Basically, some existing applications link with
lua5.1.dllwhile others link withlua51.dlland they want to support them both. In any case this is not related to the stub libraries.