FFI symbol resolution problems on Windows

  • From: Konstantin Olkhovskiy <lupus@xxxxxxxxxx>
  • To: luajit <luajit@xxxxxxxxxxxxx>
  • Date: Tue, 16 Dec 2014 13:55:51 +0400

Hi list,

I'm having some problems while trying to use libapr via ffi on windows.

I have LuaJIT compiled statically via mingw cross compilation, and libapr
1.5 compiled
dynamically via mingw (native, it refused to cross compile). The
application works fine
under linux, but when ran under Windows, it complains about the following:

cannot resolve symbol 'apr_env_get': The specified procedure could not be
found.

objdump on the libapr dll says the following:

[1510](sec  1)(fl 0x00)(ty  20)(scl   2) (nx 0) 0x000154d0 _apr_env_get@12

So the symbol is decorated with an underscore and that 'at' number.
Internets suggest
that LuaJIT should find it despite of the decoration, but so far I was
unable to get it
working. gcc -E says that macros should expand to the following:

__attribute__((dllimport)) apr_status_t __attribute__((__stdcall__))
apr_env_get(<...>);

I've tried using that as is with no luck. Same without any attributes. Also
I've tried this:

 __declspec(dllexport) apr_status_t __attribute__((__stdcall__))
apr_env_get(<...>);

Any help appreciated!
-- 
Regards,
Konstantin

Other related posts: