Re: luajit shared library and executable all in one (linux)

  • From: Mike Pall <mike-1411@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Tue, 4 Nov 2014 19:16:29 +0100

Cosmin Apreutesei wrote:
> The problem is that if I link the final exe with -shared, I can dlopen
> the exe but can't run it (it segfaults). OTOH if I don't link with
> -shared, I can run the exe, but can't dlopen it (I get "cannot
> dynamically load executable").

On POSIX, the exported symbols of the executable are present in
the global namespace, i.e. ffi.C.

> Luajit can't require() the bundled module either, probably
> because dlsym(NULL, symbol) doesn't work either, even though the
> symbols are present.

On POSIX, you have to export all non-hidden symbols, i.e. link the
executable with: -Wl,-E

> I realize this is a gcc/ELF question and not luajit specifc, but is
> `luajit -b` supposed to work on linux at all? If yes, does anyone know
> how to build an exe to support that option?

I hope so, since I'm developing LuaJIT on Linux ...

--Mike

Other related posts: