mwild1 / luadbi

Multi-backend SQL database library for Lua
MIT License
38 stars 14 forks source link

Installation on Debian 11 is complicated #71

Closed cweiske closed 1 year ago

cweiske commented 1 year ago

I wish it was easier to install luadbi-mysql on a recent Debian 11 system.

Problems I see:

My story

I installed prosody xmpp server freshly on a new server and copied the old configuration over. It would not start because DBI was not available:

No LuaRocks module found for DBI

So I tried to install it, but that failed:

$ luarocks install luadbi-mysql
Installing https://luarocks.org/luadbi-mysql-0.7.2-1.src.rock

Error: Could not find header file for MYSQL
  No file mysql.h in /usr/local/include
  No file mysql.h in /usr/include
  No file mysql.h in /include
You may have to install MYSQL in your system and/or pass MYSQL_DIR or MYSQL_INCDIR to the luarocks command.
Example: luarocks install luadbi-mysql MYSQL_DIR=/usr/local

So I installed the mariadb header files libmariadb-dev and tried again, but no avail - it wants a "include" subdirectory:

$ luarocks install luadbi-mysql MYSQL_DIR=/usr/include/mariadb/
Installing https://luarocks.org/luadbi-mysql-0.7.2-1.src.rock

Error: Could not find header file for MYSQL
  No file mysql.h in /usr/include/mariadb/include

So I went to /usr/include/mariadb and symlinked this directory into the include subdirectory:

$ ln -s . include

This got me one step further, but:

gcc -shared -o dbd/mysql.so dbd/common.o dbd/mysql/main.o dbd/mysql/statement.o dbd/mysql/connection.o -L/usr/include/mariadb/lib -Wl,-rpath,/usr/include/mariadb/lib -lmysqlclient
/usr/bin/ld: cannot find -lmysqlclient
collect2: error: ld returned 1 exit status

Error: Build error: Failed compiling module dbd/mysql.so

Now I had to install libmariadb-dev-compat, and that was the thing that finally made it compile.

mwild1 commented 1 year ago

I wish it was easier to install luadbi-mysql on a recent Debian 11 system.

Did you try sudo apt install lua-dbi-mysql ?

cweiske commented 1 year ago

Erm, that would have been too easy. No, I did not think of that at all :(

Sorry.

mwild1 commented 1 year ago

No worries! One thing to note about that package is that the version in Debian 11 is not compatible with Lua 5.4 (this is true of many Lua packages in Debian 11, unfortunately). The good news is that Debian 12 is around the corner, and it has Lua 5.4 compatibility.

For more information about Prosody Lua version support, see https://prosody.im/doc/release/0.12.0#lua-version-support