PtokaX forum

PtokaX => Bugs => Topic started by: ATAG on 24 July, 2009, 19:01:16

Title: require() doesn't work with lua scripts
Post by: ATAG on 24 July, 2009, 19:01:16
When i try to load a lua module (written in lua) i get this error:
Quote24.07.2009 18:49:16 - error loading module 'vhsql' from file '/home/atag/.PtokaX/libs/vhsql.lua':

   /home/atag/.PtokaX/libs/vhsql.lua: invalid ELF header

This is only PtokaX related problem, in lua commandline it works like a charm.

I can' use dofile() because this module uses a global sqlite db for all scripts :(

Version: PtokaX DC Hub 0.4.1.1 built on Jul 24 2009 18:40:37
OS: Linux 2.6.28-14-generic (i686) -> (Ubuntu 9.04)
Title: Re: require() doesn't work with lua scripts
Post by: PPK on 24 July, 2009, 23:21:19
PtokaX on unix not contains lua and not change any default lua functions :o
Title: Re: require() doesn't work with lua scripts
Post by: ATAG on 26 July, 2009, 16:56:40
Hmm.. i tried to compile PX with lua-5.1.4 (from source) but i got this:
Quote/usr/local/lib/liblua.a(loadlib.o): In function `ll_loadfunc':
loadlib.c:(.text+0xa31): undefined reference to `dlsym'
loadlib.c:(.text+0xa7c): undefined reference to `dlopen'
loadlib.c:(.text+0xa89): undefined reference to `dlerror'
loadlib.c:(.text+0xaa1): undefined reference to `dlerror'
/usr/local/lib/liblua.a(loadlib.o): In function `gctm':
loadlib.c:(.text+0x109e): undefined reference to `dlclose'
collect2: ld returned 1 exit status
make: *** [PtokaX] Error 1
atag@server:~/PtokaX$
Any idea? :(




Sorry, i've found the solution here (http://www.linuxquestions.org/questions/programming-9/linker-problems-cannot-find-dlsym-dlopen-dlerror-dlclose-720199/).

Now i get the "ivalid ELF header" error in commandline too :D




Ok, finally i found the problem. We have to add libs folder to package.path TOO
if not string.find(package.path, Core.GetPtokaXPath().."libs/?.lua", 1, 1) then
package.path = package.path..";"..Core.GetPtokaXPath().."libs/?.lua"
end
Title: Re: require() doesn't work with lua scripts
Post by: PPK on 26 July, 2009, 20:06:49
Good, nice to see that you fixed it yourself  8)