Recent Articles:About Me
I love making stuff and solving puzzles. I am mak...
Here are some Lua libraries that I have used or fi...
Intro :Trying to learn and standardize the Foreig...
This section contains links to everything related ...
Some notes on the C code of the Lua Compiler Lua ...
Table Of Contents
Finally I got around to trying out LuaRocks by installing it in my system and also creating a rockspec to add my simple Lua module in the LuaRocks collection. Here are some tips I picked up:
here. I had my script in github. One thing I did wrong was to provide an https url for github and then luarocks gives an error in installation. I had to make the URL start with
> luarocks pack mymodule-1.01-1.rockspecAnd it packed the files in a rock file.
Then I simply uploaded the rockspec and rock files on LuaRocks and my 1st Lua script is available through LuaRocks!
> luarocks make mymodule-1.01-1.rockspec
If that works and installs the rock then you can upload the rockspec and rock file to the LuaRocks server.
Installing LuaRocksInstalling LuaRocks was not as straightforward. Here are some notes to help anyone who needs some extra help:
- rootPath |- bin |- lua52.exe (Can be simply lua.exe) |- lua52.dll (or lua53.dll for Lua 5.3) |- lib |- lua52.dll |- include |- lauxlib.h |- lua.h |- lua.hpp |- luaconf.h |- lualib.h
Download LuaRocksThis page gives the download link
Install LuaRocksInstallation on windows is done by running install.bat batch file in the downloaded archive. Use install /? for all the command line options. Open a command terminal with administrator privileges. The command I used was:
install /LV 5.2 /LUA c:\my\lua\rootPath /MW /P c:\my\lua\rootPath\luarocks
/LV specifies my lua version
/LUA specifies my Lua root path which is the root directory path of the hierarchy I described above
/MW specifies I want to use mingw as my build system
/P specifies where I want the LuaRocks to be installed. LuaRocks creates the last directory (in the above case 'luarocks') and installs there.
Now the problem with this installation is that the rocks installed are not in my Lua Path. So I need to have package.path and package.cpath updated in my Lua executable so it points to the directory where LuaRocks installs its rocks.
At the end of the installation LuaRocks displays a list of paths that must be updated in the Lua executable and the command environment. For guidance on how to update the paths in the Lua executable directly see here. I simply took the text from the LuaRocks output and converted to a batch file which looks like this:
NOTE Here in the 1st Path statement I placed the luarocks bin path in front of all the previously defined paths so that when this batch file is run it places the lua executable in the luarocks installation 1st in line to run when lua is called from the command line.
I simply run this batch file to initialize my LuaRocks environment. I did not add them permanently since I have a separate Lua setup system which I use.
After the install process is done. It is best to run:
>luarocks install dkjsonThis package is needed for uploading rockspecs and may be used by LuaRocks at other times as well.
Installing a complicated rock on your LuaRocks setupHere I will list out the steps to install LuaSec using LuaRocks. The installation is not straightforward since it depends on openssl and LuaSec rockspec does not compile it and generate its dependencies. So you need to compile openssl separately and then place the dependency files in the LuaRocks tree and then run the LuaSec install. Here are the steps: