Being able to set LUA_PATH from within lua script is does not work with 5.1

I hacked code to look for LUA_PATH in our version of loadlib.c - but it only 
uses it for pname of "path" i.e. .lua files.

You could change loadlib.c code to

  /* Make 5.0 compatible to allow global LUA_PATH to be set from LUA */
  if (strcmp(pname, "path") == 0 || strcmp(pname, "cpath") == 0) {
                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
      lua_getfield(L, LUA_GLOBALSINDEX, LUA_PATH);


so that it will pick up "cpath" libraries 

Ray


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of John Labenski
Sent: Thursday, 18 May 2006 03:05
To: wxlua-users@lists.sourceforge.net
Subject: LUA_PATH (Ray) Re: [Wxlua-users] require("wx") and build stuff

On 5/17/06, Francesco Montorsi <[EMAIL PROTECTED]> wrote:
> Hi,
>     I'm experimenting with wx module and I've got a few proposals for it:
>
> 1) the luamodule.wx.lua files in wxLua/apps/luamodule/src is an example,
> isn't it ? Shouldn't then go in wxLua/samples ?
> wrapmodule.wx.lua is an utility so shouldn't it got in wxLua/utils ?

Eh... I think these are pretty specialized. But, you're probably
right, once things work they should be moved. I just put them into the
dir where I generated the shared lib since I was having trouble with
the paths for require.

> 2) I'm getting a weird behaviour of lua's require: I'd like to make the
> "luamodule" app installable in $prefix/lib/lua/5.1; however, while
> everything works as expected if I put the compiled wx.so in
> /usr/local/lib/lua/5.1, it doesn't work if I put it in /usr/lib/lua/5.1:

This is the path stuff I was talking about, it's a nightmare.

> wxlua-lua: luamodule.wx.lua:17: module 'wx' not found:
>          no field package.preload['wx']
>          no file './wx.so'
>          no file '/usr/local/lib/lua/5.1/wx.so'
>          no file '/usr/local/lib/lua/5.1/loadall.so'
> stack traceback:
>          [C]: in function 'require'
>          luamodule.wx.lua:17: in main chunk
>          [C]: ?
>
> I tried to set LUA_PATH in luamodule.wx.lua to:
> LUA_PATH="/usr/lib/lua/5.1/?.so;"
> *before* the require() call but then I get:
>
> wxlua-lua: error loading module 'wx' from file '/usr/lib/lua/5.1/wx.so':
>          /usr/lib/lua/5.1/wx.so:1: unexpected symbol near 'char(127)'
> stack traceback:
>          [C]: ?
>          [C]: in function 'require'
>          luamodule.wx.lua:17: in main chunk
>          [C]: ?
>
> that "unexpected symbol near 'char(127)'" is not clear to me !
>
> This strange behaviour (lua bug?) is easy to reproduce also putting the
> wx.so file in /usr/local/lib/lua/5.1 and then setting:
>
> LUA_PATH="/usr/local/lib/lua/5.1/?.so"
>
> So, it looks that the global variable LUA_PATH, described at
> http://www.lua.org/pil/8.1.html, does not work... is anyone able to
> reproduce this "bug" ?

LUA_PATH, I think, is a 5.0 thing, but recently Ray added some code in
our version of lua to handle it. Hopefully he (or anyone else)
understands what this is all about? I've spent far too much time
trying to understand the PATH thing and got nowhere.

I was hoping that the people who requested that require work w/ wxLua
would step forward and finish things. :)

Regards,
    John Labenski

ps. This was a reply I got on the lua-l about dlls and require, it
looks like for gcc in MSW you just link the dlls as you do the .so
files in linux. No news about MSVC.

On 5/13/06, Jérôme VUARAND <[EMAIL PROTECTED]> wrote:
> With mingw you can do exactly the same to build a wx.dll Lua module :
> wx.dll: luamodule.cpp $(OBJECTS) $(LUA_LIBS) wxLuaLib wxLuaDebugLib
> wxLuaSocketLib wxLuaBindings
>         $(CXX) $(CXXFLAGS) $(APPEXTRADEFS) -g -O -shared -o wx.dll -fpic \
>         $(LDLIBS) $(APPEXTRALIBS) \
>         luamodule.cpp
>
> The only extra thing you have to do is to check that all your
> -l$(XXXLIB) point to existing libraries. These libraries can either be
> static libs, or dll import libraries. Static libs are exactly like on
> unix (-lfoo need libfoo.a). Dll import libraries are necessary if you
> want to link dynamically to a dll. You can generate libfoo.a from
> foo.dll with the following commands :
>         impdef foo.dll > foo.def
>         libtool --kill-at --dllname foo.dll --input-def foo.def --output-lib 
> libfoo.a
>         rm foo.def
> These import libraries may already exist in the wxWidget build tree if
> you built it with mingw.
>
> Feel free to ask if I'm not clear. I had a hard time finding docs on
> the subject since everything on mingw site is outdated, but now I
> think I know the subject well.


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=k&kid0709&bid&3057&dat1642
_______________________________________________
Wxlua-users mailing list
Wxlua-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxlua-users


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642
_______________________________________________
Wxlua-users mailing list
Wxlua-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxlua-users

Reply via email to