Loading a C (binary) module

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
lmb
Prole
Posts: 2
Joined: Sun Jan 24, 2016 5:44 pm

Loading a C (binary) module

Post by lmb »

Hello,

After some years, I am using LÖVE again. I forgot how nice it was to use it! :-)

I am currently trying to load a binary Lua module (one of those written in C, compiled to a dynamic library). A thread from 2014 suggests that this is possible, but I am not being able to make it work.

When I require the module I get this:

Error: error loading module 'luasql.sqlite3' from file './luasql/sqlite3.so':
./luasql/sqlite3.so: undefined symbol: luaL_setfuncs

Apparently, the module is trying to register its functions with LÖVE's Lua state, which does not seem to provide the luaL_setfuncs function (which exists in my regular lua executable).

So, is loading of binary Lua modules in LÖVE supported? I am doing something wrong?

For completeness: I am using LÖVE 0.10.0 under 64-bit Linux (the standard LÖVE package provided by ArchLinux), but I'd be interested in running my program in other platforms (with the binary module compiled for each of them, obviously). The module I am trying to load is the SQLite3 driver of LuaSQL.

Thank you,

LMB
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Loading a C (binary) module

Post by bartbes »

LÖVE uses luajit, which is compatible with lua 5.1. luaL_setfuncs was added in lua 5.2, hence the problem. The solution is to build (or find) a lua 5.1-compatible version of the library.
User avatar
lmb
Prole
Posts: 2
Joined: Sun Jan 24, 2016 5:44 pm

Re: Loading a C (binary) module

Post by lmb »

Thanks! It is working now! :-)

Just in case someone needs to compile LuaSQL for Lua 5.1, here are the instructions (for Linux, at least): just edit the file named `config` on the root of the LuaSQL sources and change the line

LUA_SYS_VER ?= 5.2

to

LUA_SYS_VER ?= 5.1

Then, just build normally. You now have a module compatible with Lua 5.1 and LÖVE. You'll need to have Lua 5.1 installed on your system.

Cheers,

LMB
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 9 guests