Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows: entrypoint not found in DLL #42

Open
madmaxoft opened this issue Mar 21, 2018 · 4 comments
Open

Windows: entrypoint not found in DLL #42

madmaxoft opened this issue Mar 21, 2018 · 4 comments

Comments

@madmaxoft
Copy link

madmaxoft commented Mar 21, 2018

I'm able to install lua-zlib using LuaRocks on my Windows system. However, when trying to load lua-zlib, using require("zlib"), I get an OS error dialog for lua.exe, saying "entry point crc32_combine could not be located in the dynamic link library zlib.dll".

Upon further inspection, I found out that Windows will not load the zlib.dll that is the dependency of (lua-)zlib.dll, because it thinks it's already loaded, and it will try to load the zlib entrypoints from the lua-zlib DLL. From MS docs: If a DLL with the same module name is already loaded in memory, the system uses the loaded DLL, no matter which directory it is in. The system does not search for the DLL.

There are two fixes for this, neither seems currently doable:

  • rename lua-zlib's DLL to some other name (which also changes the "require string", as asked in Naming conflict #24)
  • use static zlib

Can you advise what to do now? Thanks

@madmaxoft
Copy link
Author

I have successfully done the second option - use static zlib.
If anyone runs into the same problem, here's how to fix this:

  1. Assuming you have a functional zlib library installed in c:\lib\zlib (Download from https://zlib.net , use cmake to generate VS solution (with param -DCMAKE_INSTALL_PREFIX=c:\lib\zlib), then build the INSTALL project from that solution, using Release mode settings)
  2. Download the luarock:
mkdir c:\lib\lua-zlib
c:
cd \lib\lua-zlib
luarocks download lua-zlib
  1. Edit the c:\lib\lua-zlib\lua-zlib*.rockspec file, add , "ZLIB_STATIC" to build.modules.zlib.defines, change platform.windows.modules.zlib.libraries from "$(ZLIB_LIBDIR)/zlib" to "$(ZLIB_LIBDIR)/zlibstatic"
  2. Install the luarock from local source:
c:
cd \lib\lua-zlib
luarocks install lua-zlib*.rockspec

(change the filename to match the existing one)

@madmaxoft
Copy link
Author

Sorry that I don't have enough luarocks rockspec knowledge to make this into a PR that wouldn't break other platforms :(

@rjallanreal
Copy link

thank you for documenting this

@Fripine
Copy link

Fripine commented Sep 14, 2024

Thank you for recording the solution, it is very helpful to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants