Search code examples
lualuasocket

How to install Lua libraries on separate folder


Hello i would like to change folder that luasocket is installing to how can i do that ? My plan is at the end i want to export my lua file as exe and use it to run my server. I want to put luasocket inside Project file so other windows computer wont have problems (I am using Windows computer too). Thanks for helping.

my code

Main.lua

lpackage.path = package.path..';./libs/lua/?.lua'
package.cpath = package.cpath..';./libs/socket/?.dll;'

This is my Project tree
Project
-libs
--lua


Solution

  • Assuming you keep the name of the luasocket DLL the same (which is usually, core.dll), you need to use ./libs/?.dll instead of ./libs/socket/?.dll, as the question mark will be replaced with socket/core when socket.core module is required from socket.lua. You'll need to put core.dll in libs/socket folder.

    You will also need to have lua.dll present (as the core.dll is usually compiled against it) or use a proxy dll if your executable statically compiles lua interpreter.