Lua 5.1 static linkage?

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

Lua 5.1 static linkage?

Stuart Scandrett
Hi all, I'm new to the Lua scene and starting to get things compiling under Win32 (Visual Studio 2k5) and have a few questions:

1) My very simple test only does the following things:

void MyLuaTest()
{
    lua_State* L = lua_open();
    luaL_openlibs(L);
    ...

The latter function I understand is the helper to replace the 5.0 scheme of luaopen_*. Unfortunately this only gets so far...

>    test.exe!setprogdir (lua_State * L=0x009da450)  Line 106    C
     test.exe!setpath(lua_State * L=0x009da450, const char * fieldname=0x004e6470, const char * envname=0x004e6680, const char * def=0x004e668c)  Line 605 + 0x9 bytes    C
     test.exe!luaopen_package(lua_State * L=0x009da450)  Line 650 + 0x18 bytes    C
     test.exe!luaD_precall(lua_State * L=0x009da450, lua_TValue * func=0x009da718, int nresults=0)  Line 319 + 0x16 bytes    C
     test.exe!luaD_call (lua_State * L=0x009da450, lua_TValue * func=0x009da718, int nResults=0)  Line 376 + 0x11 bytes    C
     test.exe!lua_call(lua_State * L=0x009da450, int nargs=1, int nresults=0)  Line 775 + 0x11 bytes    C
     test.exe!luaL_openlibs (lua_State * L=0x009da450)  Line 35 + 0xd bytes    C
     test.exe!MyLuaTest()  Line 25 + 0x9 bytes    C++

Because the Windows API call GetModuleFileName() in setprogdir() is failing I believe due to the fact that I am statically linking the Lua library into my code. Is this supported? It seemed to work fine with the 5.0 libraries, but a quick search in those didn't reveal similar path-grabbing functionality. Should I just dynamically link and be done with it?

2) Does defining LUA_COMPAT_GETN in luaconf.h interfere with the new length operator functionality? I ask because I also wish to try out LuaBind which seems to rely on it to compile. I realize that library has its own mailing list, but this one seems substantially more active and I would guess someone has LuaBind running with 5.1...

Thanks a lot! I'm excited to see what's behind the good word for the language

Stuart

Reply | Threaded
Open this post in threaded view
|

RE: Lua 5.1 static linkage?

Stuart Scandrett-2
>Because the Windows API call GetModuleFileName() in setprogdir() is failing

Mystery solved on this one. Looks like my project was defaulting to Unicode
support (groan) so the string it returned was in wchar's.


Reply | Threaded
Open this post in threaded view
|

Re: Lua 5.1 static linkage?

Mike Pall-4-2
Hi,

Stuart Scandrett wrote:
> >Because the Windows API call GetModuleFileName() in setprogdir() is failing
>
> Mystery solved on this one. Looks like my project was defaulting to Unicode
> support (groan) so the string it returned was in wchar's.

Oops. I guess it may be better to use GetModuleFileNameA() in
setprogdir(). Any objections from the Windows experts?

Bye,
     Mike
Reply | Threaded
Open this post in threaded view
|

Re: Lua 5.1 static linkage?

D Burgess-4
Why is GetModuleFileNameA() failing?

On 4/23/06, Mike Pall <[hidden email]> wrote:

> Hi,
>
> Stuart Scandrett wrote:
> > >Because the Windows API call GetModuleFileName() in setprogdir() is failing
> >
> > Mystery solved on this one. Looks like my project was defaulting to Unicode
> > support (groan) so the string it returned was in wchar's.
>
> Oops. I guess it may be better to use GetModuleFileNameA() in
> setprogdir(). Any objections from the Windows experts?
>
> Bye,
>      Mike
>
Reply | Threaded
Open this post in threaded view
|

Re: Lua 5.1 static linkage?

Stuart Scandrett-2
That was my mistake. The API call itself didn't fail, but the subsequent
strrchr() was stopping at the first 0 character which happened immediately
due to the set of wchar's returned by the call.

>From: "D Burgess" <[hidden email]>
>Reply-To: Lua list <[hidden email]>
>To: "Lua list" <[hidden email]>
>Subject: Re: Lua 5.1 static linkage?
>Date: Sun, 23 Apr 2006 08:58:37 +1000
>
>Why is GetModuleFileNameA() failing?
>
>On 4/23/06, Mike Pall <[hidden email]> wrote:
> > Hi,
> >
> > Stuart Scandrett wrote:
> > > >Because the Windows API call GetModuleFileName() in setprogdir() is
>failing
> > >
> > > Mystery solved on this one. Looks like my project was defaulting to
>Unicode
> > > support (groan) so the string it returned was in wchar's.
> >
> > Oops. I guess it may be better to use GetModuleFileNameA() in
> > setprogdir(). Any objections from the Windows experts?
> >
> > Bye,
> >      Mike
> >


Reply | Threaded
Open this post in threaded view
|

Re: Lua 5.1 static linkage?

D Burgess-4
In reply to this post by Mike Pall-4-2
Pandoras box. GetModuleFileNameA would seem a fair
compromise.

DB
Reply | Threaded
Open this post in threaded view
|

Re: Lua 5.1 static linkage?

Wim Couwenberg-2
In reply to this post by Mike Pall-4-2
> Oops. I guess it may be better to use GetModuleFileNameA() in
> setprogdir(). Any objections from the Windows experts?

Why not just compile Lua with UNICODE undefined..?  Personally I'd
prefer GetModuleFileName, since this is the documented (and therefore
official?) API entry, even though it's an alias for either the A or W
version.

--
Wim