Best way for a Lua script to call C shared lib?

I get more from the Python background and CTYPES ... and try to develop the best way to call the standard C shared lib from a Lua script.

I heard about Alien (http://alien.luaforge.net/), but not sure how relevant it is? Is the meaning updated?

For example, I know that this is the SQLite Lua library, but let me say that I want to call the shared SQLite library that is created when SQLIte is compiled?

So for example: In my case, lib is in / usr / local / lib / libsqlite 3.so

If I write a little dummy script to see if it can load lib

require "libsqlite3"

print "hello"

I get the following error:

debian@debian:~/Desktop/SQLite Test$ lua sqlite_test.lua
lua: error loading module 'libsqlite3' from file '/usr/local/lib/lua/5.2/libsqlite3.so':
    /usr/local/lib/lua/5.2/libsqlite3.so: undefined symbol: luaopen_libsqlite3
stack traceback:
    [C]: in ?
    [C]: in function 'require'
    sqlite_test.lua:1: in main chunk
    [C]: in ?
debian@debian:~/Desktop/SQLite Test$ 

Does this mean that Lua cannot call shared libraries out of the box and that I should use something like Alien?

, lib , Lua, " Lua"... , , "" .

; -)

+5
2

Lua C . libffi , , ctypes.

, lua , , , lua lua .

Alien - libffi .

+4

, Lua C. , API . , Lua, wiki, LuaRocks LuaDist.

, Alien, C libffi.

- Sqlite3, 2 :

+4

All Articles