What is the purpose of lll stubs for windows

I am considering including Lua in a C ++ project and am a little confused by the presence of two files (lua51.dll and lua5.1.dll) in the distribution from Luabinaries .

According to the docs ...

On Windows, your library or application must be linked with a stub library. stub library is a library with function declarations that will link your DLL with Lua DLL.

Why? Have I ever needed DLLs before linking with third party DLLs?

+2


a source to share


2 answers


A stub library is a file .lib

, not a DLL. It contains function declarations for all exported functions in the DLL, which simply redirect the call to the DLL itself. So if you create an application that you want to link to lua51.dll

, you point the linker to lua51.lib

and all calls to the exported functions will be redirected to the DLL. If you haven't, you will get many "unresolved external symbols" errors when linking.

This is only necessary when statically linking to a DLL (so that it is automatically loaded when the application starts up). This is not required when dynamically loading a DLL with LoadLibrary

.

Regarding why they have two different DLLs, the manual says the following:



The LuaBinaries DLL packages have a proxy dll called "lua51.dll". It can be used to replace other "lua51.dll" released by other distributions. It simply redirects the calls to "lua5.1.dll". There is no compiled source in the shipment.

Basically, some existing apps are linked to lua5.1.dll

and others are linked to lua51.dll

, and they want to support both of them. This is not related to stub libraries anyway.

+7


a source


I believe it has something to do with __declspec (import) and __declspec (export) with GetProcAddress. However, I really don't know for sure.



0


a source







All Articles