From: yahoo <mar...@ya...> - 2006-02-28 00:31:33
Attachments:
Capture-1.jpg
|
Hello, I'm using wxlua for many years. I have a problem on using luasocket 2.0. Can I load a lua dll module with require? ---- script dofile([[D:\lua\lua5\5.0\bin\compat-5.1.lua]] ) http = require("socket.http") b, c, h = http.request("http://www.lua.org") print(b,c,h) ---- With lua.exe it's ok. But with wxlua.exe I get errors. What is wrong? ----------- Marcos |
From: Marcos <mar...@ya...> - 2006-02-28 01:17:13
Attachments:
Capture-1.jpg
|
Hello, I'm using wxlua for many years. I have a problem on using luasocket 2.0. Can I load a lua dll module with require? ---- script dofile([[D:\lua\lua5\5.0\bin\compat-5.1.lua]] ) local http = require("socket.http") b, c, h = http.request("http://www.lua.org") print(b,c,h) ---- With lua.exe it's ok. But with wxlua.exe I get errors. What is wrong? ----------- Marcos W. |
From: John L. <jla...@gm...> - 2006-02-28 01:50:34
|
On 2/27/06, Marcos <mar...@ya...> wrote: > I'm using wxlua for many years. Great. > I have a problem on using luasocket 2.0. > > Can I load a lua dll module with require? > ---- script > > dofile([[D:\lua\lua5\5.0\bin\compat-5.1.lua]] ) > local http =3D require("socket.http") > b, c, h =3D http.request("http://www.lua.org") print(b,c,h) > I haven't tried this myself. > With lua.exe it's ok. > But with wxlua.exe I get errors. > > What is wrong? The error dialog you get (IIRC) is a generic MSVC dialog saying that someone is trying to write past the end of some allocated memory. Did you compile wxLua and luasocket yourself? What wxLua are you using, the cvs version from sourceforge or the original? Can you run it in a debugger? Do you get the same error for other functions in luasocket or just http.req= uest? I see you load compat-5.1.lua, wxLua is based on 5.0.2, has luasocket been compiled for 5.1? If you don't compile it yourself you may want to try this newer version out= . http://wxlua.sourceforge.net/wxLua-2.6.2.1-setup.exe I hope my questions can give you some ideas of how to solve this. Unfortunately the text in the dialog isn't enough to say anything definitively. John Labenski |
From: Marcos <mar...@ya...> - 2006-02-28 02:54:56
|
John, Sorry, my bad english, I'm brazilian. I'm compiling wxlua myself. I'am using the luasocket 2.0 binary files on win32 (win98). > I see you load compat-5.1.lua, wxLua is based on 5.0.2, has luasocket > been compiled for 5.1? No, luasocket was been compiled for 5.0.2, but under compat-5.1 package model. I download your wxLua installer e try ... the script is: --- dofile([[D:\lua\lua5\5.0\bin\compat-5.1.lua]] ) local http = require("socket.http") print(http.request) b, c, h = http.request("http://www.lua.org") print(b,c,h) --- I get this message with lua.exe and wxlua.exe --- wxLua: Error while running chunk compat-5.1.lua:130: error loading package `socket.core' (One of the library files needed to run this application cannot be found. ) --- Now I put lua50.dll (luasocket dependencie ) in /bin, and get this. ---- C:\App\wxLua\test\socket>C:\App\wxLua\bin\lua.exe http1.lua function: 00AC4780 C:\APP\WXLUA\BIN\LUA.EXE: not enough memory stack traceback: [C]: in function `request' http1.lua:4: in main chunk [C]: ? --- Note the module was loaded and http.request is a function. -------- Marcos W. _______________________________________________________ Yahoo! Acesso Grs - Internet rda e grs. Instale o discador agora! http://br.acesso.yahoo.com |
From: John L. <jla...@gm...> - 2006-02-28 04:43:31
|
On 2/27/06, Marcos <mar...@ya...> wrote: > I'm compiling wxlua myself. > I'am using the luasocket 2.0 binary files on win32 (win98). > > > I see you load compat-5.1.lua, wxLua is based on 5.0.2, has luasocket > > been compiled for 5.1? > No, luasocket was been compiled for 5.0.2, but under compat-5.1 package > model. > > I download your wxLua installer e try ... > > the script is: > --- > dofile([[D:\lua\lua5\5.0\bin\compat-5.1.lua]] ) > local http =3D require("socket.http") > print(http.request) > b, c, h =3D http.request("http://www.lua.org") print(b,c,h) > --- > > I get this message with lua.exe and wxlua.exe > --- > wxLua: Error while running chunk > compat-5.1.lua:130: error loading package `socket.core' (One of the > library files needed to run this application cannot be found. > ) > --- > > Now I put lua50.dll (luasocket dependencie ) in /bin, and get this. > ---- > C:\App\wxLua\test\socket>C:\App\wxLua\bin\lua.exe http1.lua > function: 00AC4780 > C:\APP\WXLUA\BIN\LUA.EXE: not enough memory > stack traceback: > [C]: in function `request' > http1.lua:4: in main chunk > [C]: ? > --- > > Note the module was loaded and http.request is a function. Well, it seems a little closer. I've tried it in linux, I got the luasocket source compiled it, but I had to make some changes, but it still doesn't even work using the lua executable. luasocket.h & luasocket.c I added LUASOCKET_API int luaopen_socket(lua_State *L); LUASOCKET_API int luaopen_socket(lua_State *L) { return luaopen_socket_core(L); } since otherwise I got this error when just running it in lua ../../wxLua/bin/lua: .../wxLua/luasocket-2.0/src/compat-5.1r4/compat-5.1.lua:125: error loading package `socket' (./socket.so: undefined symbol: luaopen_socket) I tried changing the require code to local http =3D require("socket") to not get the error ../../wxLua/bin/lua: .../wxLua/luasocket-2.0/src/compat-5.1r4/compat-5.1.lua:171: package `socket.http' not found but now I get this error, since it didn't load the http module. ../../wxLua/bin/lua: wxlua_test.lua:9: attempt to call field `request' (a nil value) I'm a little unfamiliar with the module way of doing things, but something not right about the luasocket lib or my paths or... something. I'm a little suspicious since it was looking for a function called luaopen_socket which didn't even exist, so I think there may be other problems in the luasocket module. It would be nice to get this working in wxLua, but if I can't even get it to work using lua, I won't be able to make any progress. I'll try tomorrow in MSW. Regards, John Labenski |
From: John L. <jla...@gm...> - 2006-02-28 21:23:10
|
Ok, I hacked away a bit, it's not pretty, but I got it to work in MSW. I downloaded the sources for luasocket-2.0.tar.gz. Compiled it using MSVC 2005 express using the sln file, I had to edit the *.vcproj to point to wxLua/module/lua/include for the include path to lua.h. I edited mime.h/c and added MIME_API int luaopen_mime(lua_State *L); MIME_API int luaopen_mime(lua_State *L) { return luaopen_mime_core(L); } edited socket.h/c and added LUASOCKET_API int luaopen_socket(lua_State *L); LUASOCKET_API int luaopen_socket(lua_State *L) { return luaopen_socket_core(L); } *** I don't know why I have to do that? I then created a dir called "socket" and "mime" in the luasocket-2.0/src dir and copied (not moved) all the lua files into them. I moved src/mime.dll to src/mime/core.dll and src/socket.dll to src/socket/core.dll. You HAVE TO either delete src/socket.dll and src/mime.dll or get rid of them somehow, otherwise require tries to load them instead of mime.lua and socket.lua and they have to both be called core.dll. src/mime.lua -- these two are already there, leave others too src/socket.lua src/mime/core.dll src/socket/core.dll src/socket/ftp.lua src/socket/http.lua src/socket/smtp.lua src/socket/socket.lua src/socket/tp.lua src/socket/url.lua I edited src/compat/compat5.1r4/compat5.1.lua to have this package.cpath =3D os.getenv("LUA_CPATH") or "./?.dll;" .. instead of ?.so for unix systems. I could have just used the environment variables, but after some debugging about why it couldn't find the libs I just left it the way I had it. It works! Both using the lua.exe program and wxlua.exe. I ran the programs from the luasocket-2.0/src dir like this ../../wxLua/bin/wxlua.exe wxlua_socket.lua (the name I gave your program) (note also I'm using cygwin in Windows so I use forward slashes) I made some tweaks to wxLua.exe to make it handle the errors a little bette= r. I'm not sure that this helps at all since I really just trashed things, but the problem you have is with the paths not being right and it not being able to find either the lua or dll files for the module's require. To help debug things change src/compat/compat5.1r4/compat5.1.lua At the top add the "print" to this list of functions local print, assert, error, getfenv, ipairs, loadfile, loadlib, pairs, setfenv, setmetatable, type =3D print, assert, error, getfenv, ipairs, loadfile, loadlib, pairs, setfenv, setmetatable, type then later on add some "print" statements local function search (path, name) ... print("search ", c) local function loader_C (name) print("loader_C ", name) local function loader_Lua (name) print("loader_Lua ", name) and whatever else seems necessary to help you understand why it cannot find what it's looking for. Good luck, John Labenski On 2/27/06, John Labenski <jla...@gm...> wrote: > On 2/27/06, Marcos <mar...@ya...> wrote: > > I'm compiling wxlua myself. > > I'am using the luasocket 2.0 binary files on win32 (win98). > > > > > I see you load compat-5.1.lua, wxLua is based on 5.0.2, has luasocket > > > been compiled for 5.1? > > No, luasocket was been compiled for 5.0.2, but under compat-5.1 package > > model. > > > > I download your wxLua installer e try ... > > > > the script is: > > --- > > dofile([[D:\lua\lua5\5.0\bin\compat-5.1.lua]] ) > > local http =3D require("socket.http") > > print(http.request) > > b, c, h =3D http.request("http://www.lua.org") print(b,c,h) > > --- > > > > I get this message with lua.exe and wxlua.exe > > --- > > wxLua: Error while running chunk > > compat-5.1.lua:130: error loading package `socket.core' (One of the > > library files needed to run this application cannot be found. > > ) > > --- > > > > Now I put lua50.dll (luasocket dependencie ) in /bin, and get this. > > ---- > > C:\App\wxLua\test\socket>C:\App\wxLua\bin\lua.exe http1.lua > > function: 00AC4780 > > C:\APP\WXLUA\BIN\LUA.EXE: not enough memory > > stack traceback: > > [C]: in function `request' > > http1.lua:4: in main chunk > > [C]: ? > > --- > > > > Note the module was loaded and http.request is a function. > > Well, it seems a little closer. I've tried it in linux, I got the > luasocket source compiled it, but I had to make some changes, but it > still doesn't even work using the lua executable. > > luasocket.h & luasocket.c I added > > LUASOCKET_API int luaopen_socket(lua_State *L); > > LUASOCKET_API int luaopen_socket(lua_State *L) { > return luaopen_socket_core(L); > } > > since otherwise I got this error when just running it in lua > ../../wxLua/bin/lua: > .../wxLua/luasocket-2.0/src/compat-5.1r4/compat-5.1.lua:125: error > loading package `socket' (./socket.so: undefined symbol: > luaopen_socket) > > I tried changing the require code to > local http =3D require("socket") > > to not get the error > ../../wxLua/bin/lua: > .../wxLua/luasocket-2.0/src/compat-5.1r4/compat-5.1.lua:171: package > `socket.http' not found > > but now I get this error, since it didn't load the http module. > ../../wxLua/bin/lua: wxlua_test.lua:9: attempt to call field `request' > (a nil value) > > I'm a little unfamiliar with the module way of doing things, but > something not right about the luasocket lib or my paths or... > something. I'm a little suspicious since it was looking for a function > called luaopen_socket which didn't even exist, so I think there may be > other problems in the luasocket module. > > It would be nice to get this working in wxLua, but if I can't even get > it to work using lua, I won't be able to make any progress. I'll try > tomorrow in MSW. > > Regards, > John Labenski > |
From: Marcos <mar...@ya...> - 2006-03-04 18:12:29
|
Thanks, John I will try. But, I think wxlua.exe must correctly use the require function without recompile libraries, because my goal is to use the binaries disposed on the web. Example is luasql, luazip, luasocket and so.. Another question is: You have a project to build wxLua module(dll,so) for dynamic load with lua.exe? Thanks in advance Marcos W. -------------- Em Tue, 28 Feb 2006 18:23:03 -0300, John Labenski <jla...@gm...> escreveu: > Ok, I hacked away a bit, it's not pretty, but I got it to work in MSW. > I downloaded the sources for luasocket-2.0.tar.gz. Compiled it using > MSVC 2005 express using the sln file, I had to edit the *.vcproj to > point to wxLua/module/lua/include for the include path to lua.h. > > I edited mime.h/c and added > MIME_API int luaopen_mime(lua_State *L); > MIME_API int luaopen_mime(lua_State *L) { > return luaopen_mime_core(L); > } > > edited socket.h/c and added > LUASOCKET_API int luaopen_socket(lua_State *L); > LUASOCKET_API int luaopen_socket(lua_State *L) { > return luaopen_socket_core(L); > } > > *** I don't know why I have to do that? > > I then created a dir called "socket" and "mime" in the > luasocket-2.0/src dir and copied (not moved) all the lua files into > them. I moved src/mime.dll to src/mime/core.dll and src/socket.dll to > src/socket/core.dll. You HAVE TO either delete src/socket.dll and > src/mime.dll or get rid of them somehow, otherwise require tries to > load them instead of mime.lua and socket.lua and they have to both be > called core.dll. > > src/mime.lua -- these two are already there, leave others too > src/socket.lua > src/mime/core.dll > src/socket/core.dll > src/socket/ftp.lua > src/socket/http.lua > src/socket/smtp.lua > src/socket/socket.lua > src/socket/tp.lua > src/socket/url.lua > > I edited src/compat/compat5.1r4/compat5.1.lua to have this > > package.cpath = os.getenv("LUA_CPATH") or > "./?.dll;" .. > instead of ?.so for unix systems. I could have just used the > environment variables, but after some debugging about why it couldn't > find the libs I just left it the way I had it. > > It works! Both using the lua.exe program and wxlua.exe. I ran the > programs from the luasocket-2.0/src dir like this > ../../wxLua/bin/wxlua.exe wxlua_socket.lua (the name I gave your program) > (note also I'm using cygwin in Windows so I use forward slashes) > I made some tweaks to wxLua.exe to make it handle the errors a little > better. > > I'm not sure that this helps at all since I really just trashed > things, but the problem you have is with the paths not being right and > it not being able to find either the lua or dll files for the module's > require. > > To help debug things change src/compat/compat5.1r4/compat5.1.lua > > At the top add the "print" to this list of functions > > local print, assert, error, getfenv, ipairs, loadfile, loadlib, pairs, > setfenv, setmetatable, type = print, assert, error, getfenv, ipairs, > loadfile, loadlib, pairs, setfenv, setmetatable, type > > then later on add some "print" statements > > local function search (path, name) > ... > print("search ", c) > > local function loader_C (name) > print("loader_C ", name) > > local function loader_Lua (name) > print("loader_Lua ", name) > > and whatever else seems necessary to help you understand why it cannot > find what it's looking for. > > Good luck, > John Labenski _______________________________________________________ Yahoo! Acesso Grs - Internet rda e grs. Instale o discador agora! http://br.acesso.yahoo.com |
From: John L. <jla...@gm...> - 2006-03-04 18:32:22
|
On 3/4/06, Marcos <mar...@ya...> wrote: > But, I think wxlua.exe must correctly use the require function without > recompile libraries, because my goal is to use the binaries disposed on > the web. Example is luasql, luazip, luasocket and so.. I agree, it should work, but I'm not sure why it doesn't. wxLua shouldn't be doing anything that would affect how require works. As I said, I think it's more of a path issue than anything else since I could get it to work. You have to duplicate the path structure that lua.exe has where "require" does work for you for wxlua.exe. In fact, why not just copy wxlua.exe to where you have lua.exe working with the "require" code and see if that works? > Another question is: You have a project to build wxLua module(dll,so) for > dynamic load with lua.exe? This will take some additional work. There was a modified version of the original wxLua that could be loaded as a dll from lua.exe, but I have not attempted to look at what was necessary to make it work. I think that it is not so simple since wxWidgets has it's own event loop and so you have to install it into lua.exe's C main() somehow. Apparently it's possible, but I haven't had time to look into it. Regards, John Labenski |