TomSelleck
TomSelleck

Reputation: 6968

How to include Lua module in build

I downloaded this Lua module and installed it with make. However, when I try to use it in my code, I get the following error:

VirtualBox:~/Downloads$ lua socket_test.lua 
lua: socket_test.lua:1: module 'nixio.util' not found:
    no field package.preload['nixio.util']
    no file './nixio/util.lua'
    no file '/usr/local/share/lua/5.1/nixio/util.lua'
    no file '/usr/local/share/lua/5.1/nixio/util/init.lua'
    no file '/usr/local/lib/lua/5.1/nixio/util.lua'
    no file '/usr/local/lib/lua/5.1/nixio/util/init.lua'
    no file '/usr/share/lua/5.1/nixio/util.lua'
    no file '/usr/share/lua/5.1/nixio/util/init.lua'
    no file './nixio/util.so'
    no file '/usr/local/lib/lua/5.1/nixio/util.so'
    no file '/usr/lib/i386-linux-gnu/lua/5.1/nixio/util.so'
    no file '/usr/lib/lua/5.1/nixio/util.so'
    no file '/usr/local/lib/lua/5.1/loadall.so'
    no file './nixio.so'
    no file '/usr/local/lib/lua/5.1/nixio.so'
    no file '/usr/lib/i386-linux-gnu/lua/5.1/nixio.so'
    no file '/usr/lib/lua/5.1/nixio.so'
    no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
    [C]: in function 'require'
    socket_test.lua:1: in main chunk
    [C]: ?

And the first line of my code:

local nixio = require "nixio", require "nixio.util"

Any help would be appreciated!

Upvotes: 2

Views: 4082

Answers (1)

lhf
lhf

Reputation: 72312

I see these options:

  1. Try make install and hope that it works. Perhaps set some variable such as PREFIX nothing.

  2. Manually move dist/usr/local/share/lua/5.1/nixio to /usr/local/share/lua/5.1/nixio and dist/usr/local/lib/lua/5.1/nixio.so to /usr/local/lib/lua/5.1/nixio.so.

  3. Add the dist paths to the environment: LUA_CPATH='dist/usr/local/lib/lua/5.1/?.so;;' and LUA_PATH='dist/usr/local/share/lua/5.1/?.lua;;'.

  4. Add the dist paths in Lua: package.cpath='dist/usr/local/lib/lua/5.1/?.so;'..package.cpath and package.path='dist/usr/local/share/lua/5.1/?.lua;'..package.path.

Upvotes: 4

Related Questions