Re: Creating a statically linked executable for a LuaJIT+C program

  • From: Florian Weimer <fw@xxxxxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Sun, 28 Oct 2012 13:15:41 +0100

* Luke Gorrie:

> Is there a simple example of a very statically linked executable
> including LuaJIT that I can borrow from?

Statically linking against GNU libc does not work well because there
is system functionality which absolutely requires dynamic linking
(name resolution, user/group database, and so on).

You could try to link only the LuaJIT library statically by switching
to static linking using "-Wl,-Bstatic" before it, and back to dynamic
linking after it using "-Wl,-Bdynamic".  Not sure if this works.  You
may have to look at the "ld" invocation printed by "gcc -v" to see
what's going wrong.

You also have to compile and link on a system which has the oldest GNU
libc version you want to support (or look very closely at the
referenced symbols).


Other related posts: