Re: FFI symbol resolution problems on Windows

  • From: malkia <malkia@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Sun, 21 Dec 2014 19:14:19 -0800

Try running it through Dependency Walker http://www.dependencywalker.com/ -
the 64-bit version (assuming your app is 64-bit, or 32-bit instead). Make
sure you are logging everything - press F7 and select everything (as I
don't know on top of my head where the DLL LoadLibrary logs were). Then
check what name gets loaded by LuaJIT.

On Sun, Dec 21, 2014 at 7:26 AM, Konstantin Olkhovskiy <lupus@xxxxxxxxxx>
wrote:

> Sorry for the late response. I've created the following script (called
> test.lua):
>
> ----------------- 8< -------------------
> local ffi = require("ffi")
>
> ffi.cdef[[
> typedef int apr_status_t;
> typedef struct apr_pool_t apr_pool_t;
> apr_status_t __stdcall apr_env_get(char **value, const char *envvar,
> apr_pool_t *pool);
> ]]
>
> local apr = ffi.load("./libapr-1-0.dll") -- <-- Use the DLL name here
> print(apr.apr_env_get) -- Ought to print cdata<...>
> ----------------- 8< -------------------
>
> And here is what I got when I ran it:
>
> ----------------- 8< -------------------
> e:\luajit.exe: test.lua:10: cannot resolve symbol 'apr_env_get': The
> specified procedure could not be found.
>
> stack traceback:
>         [C]: in function '__index'
>         test.lua:10: in main chunk
>         [C]: at 0x00401e70
>
> This application has requested the Runtime to terminate it in an unusual
> way.
> Please contact the application's support team for more information.
> ----------------- 8< -------------------
>
> I guess it was unable to find the symbol and then crashed.
> Some information which might be of interest:
>
> $ file libapr-1-0.dll
> libapr-1-0.dll: PE32 executable for MS Windows (DLL) (console) Intel 80386
> 32-bit
>
>
> $ objdump -x libapr-1-0.dll
>
> libapr-1-0.dll:     file format pei-i386
> libapr-1-0.dll
> architecture: i386, flags 0x0000013b:
> HAS_RELOC, EXEC_P, HAS_DEBUG, HAS_SYMS, HAS_LOCALS, D_PAGED
> start address 0x67ec1060
>
> Characteristics 0x2106
>         executable
>         line numbers stripped
>         32 bit words
>         DLL
>
> <...>
> [1510](sec  1)(fl 0x00)(ty  20)(scl   2) (nx 0) 0x000154d0 _apr_env_get@12
>
>
> ./luajit.exe
> LuaJIT 2.0.2 -- Copyright (C) 2005-2013 Mike Pall. http://luajit.org/
> JIT: ON CMOV SSE2 SSE3 fold cse dce fwd dse narrow loop abc sink fuse
>
>
> I'm running 64bit Windows 7, both LuaJIT and libapr are compiled for 32
> bit. This
> dll is working fine in the other dll of our internal product.
>
> I'm not an expert on building DLL's on windows, so probably there is
> something
> wrong with the dll. I could upload it to some google drive if it helps.
>
> Thanks!
> --
> Regards,
> Konstantin
>



-- 
Dimiter "malkia" Stanev,
ICQ: 21875894
malkia@xxxxxxx
malkia@xxxxxxxxx

Other related posts: