luasql undefined symbol: luaopen_mysql

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

luasql undefined symbol: luaopen_mysql

Steve Kieu
Hi,

I am new to both the list and Lua so pls forgive me is my question is too dumb :-)

OK I got lua-sql-2.0.1 ; after editing the Makefile enable mysql support and etc.. make ok; go the so file. Run lua interp. and type

the current dir has a file mysql.so which is the renamed of the so file produced above.


require'mysql'

lua said:

error loading module 'mysql' from file './mysql.so':
        ./mysql.so: undefined symbol: luaopen_mysql
stack traceback:
        [C]: ?
        [C]: in function 'require'
        stdin:1: in main chunk
        [C]: ?

I think I did something wrong but got stuck. lua version 5.1 compiled src from www.lua.org and from wxlua which has the same error.

Please help.

Thank you very much.



S.KIEU


Do you Yahoo!?
Yahoo! Personals: It's free to check out our great singles!
Reply | Threaded
Open this post in threaded view
|

Re: luasql undefined symbol: luaopen_mysql

Javier Guerra Giraldez
On Sunday 07 May 2006 9:08 pm, Steve Kieu wrote:
> the current dir has a file mysql.so which is the renamed of the so file
> produced above.

don't rename the .so file; the require('xx') function call does a
loadlib('xx.so','luaopen_xx'). that means that to open the library, Lua has
to call a function with a name based on the library name.

--
Javier

attachment0 (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: luasql undefined symbol: luaopen_mysql

Steve Kieu


don't rename the .so file; the require('xx') function call does a
loadlib('xx.so','luaopen_xx'). that means that to open the library, Lua has
to call a function with a name based on the library name.
Hi, thank you but actually if I do not rename it, when make install it will symlink the library to mysql.so anyway, ; it created a dir called luasql and put the so there, symlink it to mysql.so. If I change to that dir and run lua, then do a

require'mysql' 
same error

it can load the mysql.so but unresolve symbol.

lua automatically use the current dir as the PATH to load the so file.

bye

--
Javier



S.KIEU


The LOST Ninja blog: Exclusive clues, clips and gossip.
Reply | Threaded
Open this post in threaded view
|

Re: luasql undefined symbol: luaopen_mysql

Steve Kieu
In reply to this post by Javier Guerra Giraldez

Ok I use mc and F3 to view the so file, it has the symbol

luaopen_luasqlmysql  so I guess the lib name should be

luasqlmysql.so

And just symbolic link to it solve the problem. So somehow the default configuration in the Makefile which defines  LIBNAME  and LOADLIB  is incorrect; at least in mycase.

Thank you.




Javier Guerra <[hidden email]> wrote:
On Sunday 07 May 2006 9:08 pm, Steve Kieu wrote:
> the current dir has a file mysql.so which is the renamed of the so file
> produced above.

don't rename the .so file; the require('xx') function call does a
loadlib('xx.so','luaopen_xx'). that means that to open the library, Lua has
to call a function with a name based on the library name.

--
Javier



S.KIEU


On Yahoo!7
Answers: Real people ask and answer questions on any topic.
Reply | Threaded
Open this post in threaded view
|

Re: luasql undefined symbol: luaopen_mysql

Tomas-14
  Hi Steve

> luaopen_luasqlmysql  so I guess the lib name should be
>
> luasqlmysql.so
>
> And just symbolic link to it solve the problem. So somehow the default configuration in the Makefile which defines  LIBNAME  and LOADLIB  is incorrect; at least in mycase.
  It is incorrect now, because the definition changed :-)
This code was written to the previous version of the package model,
for Lua 5.0, not for Lua 5.1.  Your solution is correct, by the way.

  Tomas