lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Mon, Jan 3, 2011 at 3:24 PM, Steve Litt <slitt@troubleshooters.com> wrote:
> Same symptom with require("posix"):
>
> ========================================
> slitt@mydesk:~/ulua/program$ ./test.lua
> /usr/bin/lua: ./test.lua:2: module 'posix' not found:
>        no field package.preload['posix']
>        no file './posix.lua'
>        no file '/usr/local/share/lua/5.1/posix.lua'
>        no file '/usr/local/share/lua/5.1/posix/init.lua'
>        no file '/usr/local/lib/lua/5.1/posix.lua'
>        no file '/usr/local/lib/lua/5.1/posix/init.lua'
>        no file '/usr/share/lua/5.1/posix.lua'
>        no file '/usr/share/lua/5.1/posix/init.lua'
>        no file './posix.so'
>        no file '/usr/local/lib/lua/5.1/posix.so'
>        no file '/usr/lib/lua/5.1/posix.so'
>        no file '/usr/local/lib/lua/5.1/loadall.so'
> stack traceback:
>        [C]: in function 'require'
>        ./test.lua:2: in main chunk
>        [C]: ?
> slitt@mydesk:~/ulua/program$
> ========================================
>
> So I'll probably just do it in C.

Steve,

It's already done in C.  From the luaposix README,

    To try this Lua library, edit Makefile to reflect your installation of Lua.
    Then run make. This will build lposix.so and run a simple test. If
everything
     is ok, install lposix.so and posix.lua in some official place....
     Here is a brief explanation of the files in this package:
     lposix.c        posix library
     ...

You don't have to require UMENU users to install a package in the
traditional sense of the word 'install'.  All you have to do is place
posix.lua (and lposix.so) in one of the places listed by the error
message.

If you don't want to stick it in one of those places, you can change
the list in your Lua script before calling require like this:
package.path = package.path .. '/usr/local/share/UMENU/?.lua'
Then the only installation required is to drop those two files into
your program folder.

See http://www.lua.org/manual/5.1/manual.html#pdf-package.loaders for
more information.

The only caveat I have for you is that building luaposix requires some
information about your installation.  If you're packaging Lua into
UMENU (which sounds like the case), this should be fairly easy.  If
you're letting your users install Lua and UMENU separately, you might
have some hiccups.  You need to tell the Makefile the following
information:

    # change these to reflect your Lua installation
    PREFIX=		/usr/local
    LUAVERSION=	5.1
    LUAINC=	 	$(PREFIX)/include
    LUALIB= 		$(PREFIX)/lib/lua/$(LUAVERSION)
    LUABIN= 		$(PREFIX)/bin

    # other executables
    LUA=			lua
    INSTALL=		install

Hope that clarifies the situation for you,
--
Kevin Vermeer