LuaSocket and LuaFileSystem for Windows

Forums: LuaSocket and LuaFileSystem for Windows
Forum for OctaneRender Lua scripting examples, discussion and support.

LuaSocket and LuaFileSystem for Windows

Postby stratified » Tue May 12, 2015 9:50 pm

stratified Tue May 12, 2015 9:50 pm
Hi guys,

External Lua C modules aren't that easy to compile on Windows so I went ahead and compiled LuaFileSystem and LuaSocket so that they can be used with Octane. I didn't bother with Linux and OSX because on those systems, the modules can be installed easily via the LuaRocks package manager.

First you need to unzip the file, it's very important to keep the directory structure intact because LuaSocket relies on this structure. Then, in your script you need to make sure that these modules can be found by require. You do this by modifying the package.path and package.cpath variables (you can read more about them here).

Here's a minimal example just to show how to load the libraries:

Code: Select all
print("------------------ LuaFileSytem -------------------")

-- make sure the lfs.dll can be found
package.cpath = package.cpath .. ";C:\\tmp\\lualibs_windows\\luafilesystem\\?.dll"

require("lfs")
print(lfs._VERSION)
-- execute some code from the LuaFileSystemLib
print(lfs.currentdir())
for it,obj in lfs.dir(lfs.currentdir()) do
    print(it)
end

print("------------------ LuaSocket -------------------")

-- LuaSocket is distributed as a dll (core.dll) and a set of wrapper lua scripts, we need to make sure that all these
-- can somehow be found by lua by fudging package.cpath and package.path
package.cpath = package.cpath .. ";C:\\tmp\\lualibs_windows\\luasocket\\mime\\?.dll"
package.cpath = package.cpath .. ";C:\\tmp\\lualibs_windows\\luasocket\\?.dll"
package.path  = package.path .. ";C:\\tmp\\lualibs_windows\\luasocket\\?.lua"

require("socket")
print(socket._VERSION)
http = require("socket.http")

-- request our home page via the socket library
local ourHome = http.request("http://render.otoy.com")
print(ourHome)


And here's the zipfile with the libraries:
lualibs_windows.zip
(1.34 MiB) Downloaded 768 times


We can add more libraries later (if they are well-supported and maintained). Obviously when don't make any guarantees about all this code and don't give any support. If anybody is interested in compiling the libraries himself, PM me and I will happily provide you with the Visual Studio project.

edit: Some users requested the Visual Studio project so I've attached it here. The solution was created in VS 2010. The archive contains:
  • The Visual Studio 2010 files.
  • The header files and pre-compiled binaries for LuaJIT 2.0.2 (they are a dependency for all the other projects).
  • Source code for Lua Filesystem version 1.6.3
  • Source code for Lua Sockets 2.0.2

lualibs_visual_studio.zip
(11.18 MiB) Downloaded 492 times


cheers,
Thomas
User avatar
stratified
OctaneRender Team
OctaneRender Team
 
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand

Re: LuaSocket and LuaFileSystem for Windows

Postby Tugpsx » Wed May 13, 2015 1:53 am

Tugpsx Wed May 13, 2015 1:53 am
Thanks, this will come in handy.
Dell Win Vista 32 | NVIDIA Quadro NVS135M | Core2 Duo T7500 2.20GHz | 4GB
CyberPowerPC Win 7 64| NVIDIA GTX660Ti (3G) GTX480(1.5G) | 16GB
Tugpsx
Licensed Customer
Licensed Customer
 
Posts: 1145
Joined: Thu Feb 04, 2010 8:04 pm
Location: Chicago, IL

Re: LuaSocket and LuaFileSystem for Windows

Postby jbarreiro » Thu May 14, 2015 1:49 am

jbarreiro Thu May 14, 2015 1:49 am
Thanks Thomas! Tested and it's all up and running!
jbarreiro
Licensed Customer
Licensed Customer
 
Posts: 1
Joined: Fri Nov 01, 2013 1:02 am

Re: LuaSocket and LuaFileSystem for Windows

Postby butterhuang » Mon Aug 24, 2015 6:40 am

butterhuang Mon Aug 24, 2015 6:40 am
Well done! can you make an OpenCV lib for windows?
butterhuang
 
Posts: 11
Joined: Mon Jun 01, 2015 5:10 am

Re: LuaSocket and LuaFileSystem for Windows

Postby stratified » Mon Jan 18, 2016 3:24 am

stratified Mon Jan 18, 2016 3:24 am
Bumping this up again.

Attached the Visual Studio 2010 project files to the original post.

cheers,
Thomas
User avatar
stratified
OctaneRender Team
OctaneRender Team
 
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand

Re: LuaSocket and LuaFileSystem for Windows

Postby lance_uppercut » Tue Dec 12, 2023 6:44 am

lance_uppercut Tue Dec 12, 2023 6:44 am
I'm trying to write a script to bring materials and assets into Standalone from Quixel Bridge, for which LuaSocket and LuaFileSystem would be extremely useful. Unfortunately they are not working for me - I tested with Octane Standalone 2024.1 Alpha, and 2022.1. Every time I run the example script, Octane runs the script for a few seconds, freezes up, and then crashes.

I built Lua on my system (Windows 11) so I tried to run the script outside of Octane, but I get this message:
Code: Select all
------------------ LuaFileSytem -------------------
lua: error loading module 'lfs' from file 'C:\Users\s_bartnicki\Code\QuixelBridgeOctane\lualibs_windows\luafilesystem\lfs.dll':
   %1 is not a valid Win32 application.

A similar message is produced by LuaSocket. I don't know if it's relevant, as I assume that the Lua on my system is quite different from the interpreter that's running in Octane.

I also tried to download and build the Visual Studio SLN that was posted, but as I have VS 2022 (Community Edition), I can't build without getting the following error:
Code: Select all
error LNK2001: unresolved external symbol __iob_func


I assume these libraries are just long outdated as they were posted in 2015. Any help would be appreciated!
lance_uppercut
Licensed Customer
Licensed Customer
 
Posts: 11
Joined: Fri Jan 23, 2015 12:51 am
Location: Toronto, Canada

Return to Lua Scripting


Who is online

Users browsing this forum: No registered users and 2 guests

Thu Mar 28, 2024 10:35 pm [ UTC ]
cron