There is a c code called lua-pack.c, provided here, which is a lua extension for process hex string, I need to use it in openresty to process some network stream.
I install it in windows with lua5.1 and luarocks
I successfully get the lua-pack.dll. All the test ran successfully in command line mode like this
lua C:\projects\lua-pack\lua-pack\test.lua
But once I put this lua-pack.dll in openresty's dir, and use it, some exception will throw like
worker process 24892 exited with code C0000005
I can successfully compile lua-pack.so (compile by makefile) in ubuntu and it functions right in openresty in linux. I tried to copy this lua-pack.so to windows, and it throws exception says this so is not for windows use.
However, I noticed that in test.lua provided here by the author it require(pack) instead of require(lua_pack)
So I renamed the lua-pack.dll to pack.dll, then I got another exception
lua entry thread aborted: runtime error: error loading module 'pack' from file '.\pack.dll':
I do notice that this is a pack.lua in lua-rocks windows, I don't know whether this matters.
test.lua provided by the author start like this, this can be run in Windows command line
require"pack"
bpack=string.pack
bunpack=string.unpack
My code works in Linux openresty start like this
local bpack, bunpack
do
local string_pack = string.pack
local string_unpack = string.unpack
require "lua_pack"
bpack = string.pack
bunpack = string.unpack
-- luacheck: globals string.unpack
string.unpack = string_unpack
-- luacheck: globals string.pack
string.pack = string_pack
end