lua-users home
lua-l archive

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


2014-08-20 12:04 GMT+01:00 Robert Brown <rebrown@exemail.com.au>:
> First step after installing lua was to get libusb installed.
> I chose to use libusb-1.0.19 from
> http://sourceforge.net/projects/libusb/files/latest/ which compiled ok from
> a tar.gz file.

Libusb is a library for the C programming language. You need a library
for the Lua programming language.

> Then I did
> cp /home/pi/libusb-1.0.19/libusb/.libs/libusb-1.0.so libusb.so
>
> and then
> sudo cp /home/pi/libusb-1.0.19/libusb.so /usr/local/lib/lua/5.1/
>
> At this point I get an error when I run
> lua
> Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio
>> require('libusb')
> error loading module 'libusb' from file './libusb.so':
>     ./libusb.so: undefined symbol: luaopen_libusb
> stack traceback:
>     [C]: ?
>     [C]: in function 'require'
>     stdin:1: in main chunk
>     [C]: ?

I'm not sure why you expect this to work. If you're not familiar with
programming: it's usually not possible to use a library written for
one language into another language. If you're familiar with
programming, but not with Lua: Lua cannot access any compiled dynamic
libraries, only ones specifically designed for Lua (ie. implementing a
predefined API).

> Can anyone offer some advice on where I go from here?

I wrote a libusb binding for Lua that you can use: http://piratery.net/luausb/

You'll probably have to get the sources and compile it yourself,
unless you have a working LuaRocks installation and a system-installed
libusb.