Open sponge opened 13 years ago
I haven't personally built it on windows but I think someone else was successful. I have a working virtual machine now so I'll try to put together some binaries.
From that error it sounds like you built enet into its own dll but not lua-enet. Lua is looking for a specially named function in the dll that it can't find. Is that a possibility?
I really can't be sure. I did eventually get it working, although I honestly don't what specific steps that worked. I believe I built ENet using the provided Visual Studio project. I had to then modify the build commands that luarocks attempted to run to link to ws2_32 and winmm. I also had to modify an #ifdef WIN32 that for some reason wasn't being hit. It was attempting to include sys/time.h for the UNIX path. My working DLL was only a few hundred kb different in size than when I first posted the ticket.
Although I was able to get the basic echo server/client to work, my main goal is to use the lib in conjunction with www.love2d.org. Attempting to load the module in a Love gets me "An application has made an attempt to load the C runtime library incorrectly" when I require enet. I'm not quite sure if this is a problem with the way I built it, or a problem with the Love stuff, but it's a definite blocker for me on using lua-enet further.
I do believe I was able to get everything including loaded into Love2D on my Mac Mini, that was definitely straightforward compared to this.
Okay I built a windows verison using mingw. I tested it with the echo servers and was able to require it in love without any errors. Give it a shot and tell me if it works.
Fantastic, it seems to be working even within Love now. Was the build process under mingw significantly different from the "configure && make && make install" dance? Mainly if I need to dive into the wrapper source it would be nice to be able to generate a working binary myself.
(BTW, do you know someone named Tim Branyen? He and I are both RIT alum, and he recognized the name when I linked him to the project! Small world.)
It was pretty straight forward. I downloaded the enet source, then did sh configure
then make
to build libenet.a. I put the enet headers and the lib I just built into my mingw installation. Then I downloaded the LuaRocks windows binaries, and pulled out the lua headers and libs and dropped them into the mingw install.
Then from a checkout of lua-enet I ran:
gcc -O -shared -o enet.dll enet.c -lenet -llua51 -lws2_32 -lwinm
There is no dependency on luarocks, I just used it for the lua binaries. You could easily use the Lua Binaries package too.
I am actually trying to build love from scratch on windows. Now that is hard ;)
(Also yeah I know Tim. I am also an RIT alum.)
It's pretty old, but is there a luarocks fix?
Still getting lua: error loading module 'enet' from file '.\enet.dll': The specified procedure could not be found.
when using the dlls provided by @leafo.
When trying to build it with luarocks I get this as well: couldn't find ENET_DIR
Any suggestions?
DONT DO THIS, it's unfortunately not working, because there might be a version missmatch to ENet!
If you stumble on this one, try the following:
Use one of the .dlls @leafo mention here
Okay I built a windows verison using mingw. I tested it with the echo servers and was able to require it in love without any errors. Give it a shot and tell me if it works.
For some reason 1.0-51 only worked for me.
And load the c package as follows:
local enet = nil
if enet == nil then
print("Checking external enet c library 'enet.dll' loading..")
enet = assert(package.loadlib(--[[ path_to_enet.dll ]], "luaopen_enet")) -- replace path_to_enet.dll
enet()
print("enet c library 'enet.dll' was loaded.")
end
https://www.lua.org/manual/5.1/manual.html#5.3 see package.loadlib (libname, funcname) package.loadlib(--[[ path_to_enet.dll ]], "*") -- asteriks isnt working in 5.1
Therefore use the standard function name to load c packages: luaopen_[libraryname]. You can find it here: https://github.com/leafo/lua-enet/blob/97d91e8c4337555425fa751f02f552bbb553f17b/enet.c#L775
I've been attempting to get the bindings building and running on Windows, and haven't had much luck. I was able to get a .dll generated but upon attempting to run the echo server example Lua outputs the following:
-- server.lua require "enet" local host = enet.host_create"localhost:6789" while true do local event = host:service(100) if event and event.type == "receive" then print("Got message: ", event.data, event.peer) event.peer:send(event.data) end end
lua: error loading module 'enet' from file '.\enet.dll': The specified procedure could not be found.
stack traceback:
I imagine I'm doing something stupid while building. Are there any binaries existing for Windows that are confirmed working? I wasn't able to get it working through luarocks (couldn't find ENET_DIR despite it being set correctly) and had to manually build it within VS2005.