[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: 回复: Re: Problem calling c++ from Lua (MS-Windows version)
- From: Michael Gogins <michael.gogins@...>
- Date: Thu, 24 Feb 2011 15:15:33 -0500
Perhaps this indicates a malformed package.cpath or LUA_CPATH
environment variable?
Regards,
Mike
On Thu, Feb 24, 2011 at 2:34 PM, jseb <gmane2010@finiderire.com> wrote:
>> A very useful tool to debug such DLL problems is Dependency Walker
>> [1]. It can tell you what dependencies a DLL has (and it displays
>> warning if it's unable to find them). It is also useful to examine
>> exported symbols, and check that your luaopen_foo is properly named
>> and not mangled.
>>
>> And to find out why -static-libgcc solves the problem, and how to
>> solve it with MSVC, you will have to provide more details, such as
>> what DLL exactly is reported missing, what unusual things you might
>> have in your PATH, or whether you may have several foo.dll files in
>> the PATH (for example one for the C/C++ library, and one for the Lua/C
>> binding module).
>>
>> [1] http://www.dependencywalker.com/
>
>
> my %PATH% was "classic", nothing strange in it (i checked it with
>
> echo $PATH | awk 'BEGIN { FS=":"} {for (i=1; i<NF; i++) print $i}'
>
> (sorry i don't know how to do it fast with Lua) )
>
> I've got only one "foo.dll". I didn't verify if windows installed one in its
> system-path, but i don't think so.
>
> I checked name mangle, which was ok with "objdump" (or "nm", don't
> remember). Anyway, compiling with static version of gcc standard lib solves
> the issue, so no name mangling here.
>
> And well i do know why i had to add "-static-libgcc".
> I wrote the short version, as the story seems to raise few interest. For
> those who are more interested, here's the full story
>
> <found on a forum>
> All MinGW executables that uses C/C++ routines, classes and libs are
> necessary linked against libgcc_s_dwxx-x.dll (GNU C lib) and
> libstdc++-xx.dll (GNU C++ STD lib) All these .dll can be found at the
> compiler's /bin directory.
> All you have to do is to copy&paste those into your main executable's path.
> For a static link version of this libs, you can add "-static-libgcc
> -static-libstdc++" to your compiler flags and you won't need this .dll
> anymore.
> Your executable will be dramatically heavier, due to the internal addition
> of their contents, but it should be OK.
> </found on a forum>
>
>
> Now, the mystery is:
> Why in shell (CMD or MSYS), during the lua's require, i got this error:
>
>> require "libfoo"
> error loading module 'libfoo' from file '.\libfoo.dll':
> Le module spécifié est introuvable.
> (above mean that "specified module could'nt be found)
>
> Ok.
> But why when i launch the lua script from explorer (in my case "total
> commander", but that's the same from explorer) i got another error ?
> This time, the error was about the missing libgcc_s...dll
>
> I can understand that i don't have problems with MSYS, but the same error
> (that is, missing GNU libc++) should raise with CMD, as it has nothing to do
> with GNU C++ standard lib.
>
> What is missing is something like "strace" under windows, which could help
> to solve this sort of issues (Lua probably hang on this, and report a very
> generic error message).
> So i will give a try for dependency-walker, next time i have a MS-windows in
> the neighborhood (no windows here for trying, sorry).
>
> I gave a try with MSVC for trying to figure it out, but i'd rather like
> using GNU's. That's odd that MSVC couldn't compile properly my lib, and
> perhaps it's another problem (i can't believe that Microsoft C++ standard
> library is missing in system32 :p ).
>
>
> Thanks for the link, i guess it will be useful next time !
>
>
>
--
Michael Gogins
Irreducible Productions
http://www.michael-gogins.com
Michael dot Gogins at gmail dot com