Forum

> > CS2D > Scripts > LuaSQL on Debian
Forums overviewCS2D overview Scripts overviewLog in to reply

English LuaSQL on Debian

17 replies
To the start Previous 1 Next To the start

old LuaSQL on Debian

Marcell
Super User Off Offline

Quote
Hey...

I trying to get work LuaSQL on debian since, on windows worked fine.

But now i trying it on linux.

Installed lua5.1 lua5.0 lua5.2 and libraries includes.
also luasql with luarocks.

but now i getting a strange error when trying to run server with the lua connection script

Somewhy its not load this module.. i tried to use google, but nothing helped. Any idea guys, developers?

LUA ERROR: error loading module 'luasql.mysql' from file '/usr/local/lib/lua/5.1
/luasql/mysql.so':
/usr/local/lib/lua/5.1/luasql/mysql.so: undefined symbol: lua_touserdata

IMG:https://kep.classrpg.net/files/16.png

old Re: LuaSQL on Debian

gotya2
GAME BANNED Off Offline

Quote
It seems that lualib is not linked with mysql.so?
Not sure how to solve it, but can you tell me how you compiled the mysql.so ?

old Re: LuaSQL on Debian

Marcell
Super User Off Offline

Quote
Easily..

Just installed LuaRocks, then downloaded luasql and built it.

I am so angry, cant get work this...
edited 1×, last 05.11.14 03:08:47 pm

old Re: LuaSQL on Debian

Starkkz
Moderator Off Offline

Quote
This is one of the reasons of why I wanted LuaJIT on CS2D, it provides a full set of C functions that you can use if libraries don't work. I've never had success at installing a Linux library for Lua, nor I know anyone that has.

old Re: LuaSQL on Debian

Marcell
Super User Off Offline

Quote
I think you also spent some hours to solve problem, but if you solved a problem, you have got an another problem. But i will solve, because i want my server to have MySQL connection..

old Re: LuaSQL on Debian

_Yank
User Off Offline

Quote
@user Marcell: No you wont, deal with it. Til DC gives us LuaJIT, we wont be able to use any special library on linux.

old Re: LuaSQL on Debian

TimeQuesT
User Off Offline

Quote
Well, you can write a program which comunicates with lua via the file system.

For example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{Lua-Instance}
Create a file with a random generated name and put mysql-instructions into it.

{Application-Instance}
Scan for files in directory every N seconds...
Open them in write & read mode to check if they're available...
	no: retry later
	yes: 1. execute read instructions...
		2. delete it...

{Lua-Instance}
Check folder for responses every N seconds.
Open them in write & read mode to check if they're available.
	yes: 1.read its data and do stuff with it.
		2. delete it.

old Re: LuaSQL on Debian

Marcell
Super User Off Offline

Quote
@user _Yank: No, i dont think its nor possible. In the life everything is possible if you believe in it

Btw, thanks TimeQuesT i will try what you saying.

old Re: LuaSQL on Debian

TimeQuesT
User Off Offline

Quote
For those who know c++ & are interested in this method: here's a simple class which makes it easier to comunicate via Filesystem.
(An example is included)

(Feel free to modificate it for your own needs)
Download

old Re: LuaSQL on Debian

DannyDeth
User Off Offline

Quote
What is the output of:
1
# ldd /usr/local/lib/lua/5.1/luasql/mysql.so

Edit: just remembered Lua is statically linked... this shouldn't yield any help.

old Re: LuaSQL on Debian

Marcell
Super User Off Offline

Quote
Quote
root@classrpg:/usr/local/lib/luarocks/rocks# ldd /usr/local/lib/lua/5.1/luasql/m
ysql.so
linux-gate.so.1 => (0xb7757000)
libmysqlclient.so.18 => /usr/lib/i386-linux-gnu/libmysqlclient.so.18 (0x
b7421000)
libc.so.6 => /lib/i386-linux-gnu/i686/cmov/libc.so.6 (0xb72bc000)
libpthread.so.0 => /lib/i386-linux-gnu/i686/cmov/libpthread.so.0 (0xb72a
2000)
libz.so.1 => /lib/i386-linux-gnu/libz.so.1 (0xb7289000)
libdl.so.2 => /lib/i386-linux-gnu/i686/cmov/libdl.so.2 (0xb7285000)
librt.so.1 => /lib/i386-linux-gnu/i686/cmov/librt.so.1 (0xb727c000)
libstdc++.so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6 (0xb7190000)
libm.so.6 => /lib/i386-linux-gnu/i686/cmov/libm.so.6 (0xb7169000)
libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0xb714c000)
/lib/ld-linux.so.2 (0xb7758000)
root@classrpg:/usr/local/lib/luarocks/rocks#

old Re: LuaSQL on Debian

DannyDeth
User Off Offline

Quote
Alright, this is a hopeful fix here. I can't test it because I'm on a Nokia phone at the moment.

You're going to have to download, unpack, modify and then make the luasql-mysql rock.

Navigate your way to some temporary place and download the luasql rock:
1
2
$ cd ~; mkdir tmp; cd tmp
$ luarocks-5.1 download luasql-mysql

Then unpack the rock and move it's rockspec into the luasql directory:
1
2
3
4
$ luarocks-5.1 unpack luasql-mysql-2.3.0-1.src.rock
$ cd luasql-mysql-2.3.0-1
$ mv luasql-mysql-2.3.0-1.rockspec luasql/
$ cd luasql

Now, edit the luasql-mysql-2.3.0-1.rockspec file. Change this:
1
2
3
4
5
6
7
8
9
10
11
build = {
	type = "builtin",
	modules = {
		["luasql.mysql"] = {
			sources = { "src/luasql.c", "src/ls_mysql.c" },
			libraries = { "mysqlclient" },
			incdirs = { "$(MYSQL_INCDIR)" },
			libdirs = { "$(MYSQL_LIBDIR)" }
		}
	}
}
To this:
1
2
3
4
5
6
7
8
9
10
11
build = {
	type = "builtin",
	modules = {
		["luasql.mysql"] = {
			sources = { "src/luasql.c", "src/ls_mysql.c" },
			libraries = { "mysqlclient", "lua5.1" },
			incdirs = { "$(MYSQL_INCDIR)" },
			libdirs = { "$(MYSQL_LIBDIR)" }
		}
	}
}

( add "lua5.1" to the libraries table )

Then you need to make the rock:
1
$ luarocks-5.1 make luasql-mysql-2.3.0-1.rockspec
If you get "Could not find expected file mysql.h", you'll want to do:
1
$ luarocks-5.1 make luasql-mysql-2.3.0-1.rockspec MYSQL_INCDIR=/usr/include/mysql

The luarocks make command needs to be run as root.

Hopefully that will fix your problem.

old Re: LuaSQL on Debian

Marcell
Super User Off Offline

Quote
OMG.

You are good.
It's fixed the problem. The problem was LUA used over version of 5.1 right?
I read something about this.

Thanks again.

old Re: LuaSQL on Debian

DannyDeth
User Off Offline

Quote
user Marcell has written
The problem was LUA used over version of 5.1 right?

No, the problem was that the luarocks wasn't linking the Lua library when building the mysql object, as was already pointed out by user gotya2. Pleased to have been of aid.

old Working?

Happy Camper
User Off Offline

Quote
Sorry for reviving an old thread.

I'm a bit curious if you got this working? I have tried it, and it seems to work fine for a while, but suddenly the CS2D process crashes. It's always something memory related, e.g.:
1
*** Error in `./cs2d_dedicated': free(): invalid pointer: 0x081a485c ***
I did some quick research and I think the reason could be that the MySQL lib is linked with an external Lua lib, instead of the one included in the CS2D binary:
Quote
My guess is that you're ending up with two instances of liblua. That won't work.

http://lua-users.org/lists/lua-l/2006-12/msg00523.html

Here's another thread describing a similar problem:

https://github.com/zdevito/terra/issues/6

A solution could be that the CS2D binary exports all symbols from the Lua lib. Obviously, this is out of our hands. It has to be done by DC.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview