Use Lua libraries from within script

86 views
Skip to first unread message

TJ Moretto

unread,
Oct 15, 2018, 10:00:18 PM10/15/18
to Orthanc Users
Hi - New to Lua... Does anyone know if it's possible to install and use Lua libraries (say via LuaRocks) within the Orthanc Lua scripting engine?  Tried installing as part of my Dockerfile, but getting an error "Lua interpreter not found in $PATH".

Sébastien Jodogne

unread,
Oct 16, 2018, 2:29:32 PM10/16/18
to Orthanc Users

TJ Moretto

unread,
Oct 24, 2018, 9:52:11 AM10/24/18
to Orthanc Users
Thanks for that!  I'm using the orthanc-plugins Docker image, v1.4.2.  Getting an error trying to load an external Lua lib:


E1023 13:38:07.650811 LuaContext.cpp:590] Error while executing Lua script: error loading module 'lfs' from file '/usr/local/lib/lua/5.2/lfs.so':
dynamic libraries not enabled; check your Lua installation


If I require it from the lua console and use the lib, it works fine.

Any ideas what I'm doing wrong? 

Alain Mazy

unread,
Oct 24, 2018, 12:11:42 PM10/24/18
to TJ Moretto, orthan...@googlegroups.com
have you tried pulling the 1.4.2 image again since it has been updated ?
docker pull jodogne/orthanc-plugins:1.4.2
--

Alain Mazy / CTO 
a...@osimis.io / +32 494 31 67 27

Osimis

OSIMIS S.A. 
Quai Banning 6BE-4000 Liège 
www.osimis.io

Twitter LinkedIn


TJ Moretto

unread,
Oct 25, 2018, 9:01:25 AM10/25/18
to Orthanc Users
Pruned all my docker images, re-pulled, and re-built.  Same error.

Sébastien Jodogne

unread,
Oct 26, 2018, 4:18:43 AM10/26/18
to Orthanc Users
It does work. Here is a full sample session:

$ sudo docker pull jodogne/orthanc
$ sudo docker run -i -t --rm --entrypoint=bash jodogne/orthanc

root@da959f58e39f:~# apt-get update
root@da959f58e39f:~# apt-get install liblua5.1-socket
root@da959f58e39f:~# cat << EOF > Sample.json
{
"LuaScripts" : [ "Sample.lua" ]
}
EOF

root@da959f58e39f:~# cat << EOF > Sample.lua
socket = require ("socket")
EOF

root@da959f58e39f:~# LUA_PATH=/usr/share/lua/5.1/?.lua LUA_CPATH=/usr/lib/x86_64-linux-gnu/lua/5.1/?.so Orthanc Sample.json

Regards,
Sébastien-

Sébastien Jodogne

unread,
Jan 29, 2019, 9:40:10 AM1/29/19
to Orthanc Users
NB: The instructions above are valid for jodogne/orthanc:1.4.2, but not for jodogne/orthanc:1.5.0, because Lua has been upgraded from version 5.1.5 to version 5.3.5 in Orthanc 1.5.0, and because Lua modules are only binary compatible if their major.minor version are the same.
Reply all
Reply to author
Forward
0 new messages