Re: FFI symbol resolution problems on Windows

  • From: Konstantin Olkhovskiy <lupus@xxxxxxxxxx>
  • To: luajit <luajit@xxxxxxxxxxxxx>
  • Date: Thu, 25 Dec 2014 18:56:25 +0400

2014-12-23 7:36 GMT+03:00 Konstantin Olkhovskiy <lupus@xxxxxxxxxx>:

> I glanced at the list of symbols, which dependency walker shows, and for
> some
> reason it does not have underscores, i.e. "apr_env_get@12", while objdump
> claims it's there. So the dll is likely broken and it should be the root
> cause, right?
>

It turned out that mingw does not add underscores for stdcall functions. I
managed
to solve this problem in the following way: compiled apr and aprutil as a
static .a lib
using native mingw on windows (as I stated before it refuses to cross
compile in a
straightforward way), copied the resulting prefix dir onto MXE cross
environment
root and linked against it from the main library project. The resulting dll
did not have
the symbols from libapr and libaprutil, but adding the following liker
flags:

-Wl,--export-all-symbols -Wl,--add-stdcall-alias

made mingw export apr symbols (still no underscore, but with 'at') and add
an alias
for each of those without the 'at', which makes LuaJIT pick that symbols as
it first
tries the undecorated version.

kolkhovskiy@kolkhovskiy-vb /e
$ ./luajit.exe test.lua
cdata<int ()>: 0x677cd3f0

Looks we're good :)

Thanks for your help!

-- 
Regards,
Konstantin

Other related posts: