[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: static linking with lua
- From: "Robert G. Jakabosky" <bobby@...>
- Date: Sat, 5 Mar 2011 18:21:12 -0800
On Saturday 05, Sam Roberts wrote:
> > Lua C modules need to resolve symbols to the Lua C API (dynamically at
> > runtime). If you statically compile/link your whole program, then those
> > symbols will not be available to the dynamic linker.
> > So basically you can't dynamically load Lua C modules into a statically
> > compiled program.
> Perhaps I misunderstand what you all mean by static, but the standard
> lua binary is statically linked to the lua runtime, and can call
> dlopen(), check its build options in the Makefile.
> IIRC, there is an option to tell gcc to statically link, but export
> the symbols, those exported symbols are then available to modules when
> they are loaded.
I was talking about a purely static binary without ld.so dynamic linker
support. The OP was building a static binary for an initrd (linux kernel boot
image). Which normally only has purely static binaries (i.e. no dynamic ld.so
support to keep the binaries small with as few dependency as possible).
Now he might still be able to use dynamic module support if the binary has all
symbols exported (with the linker options Doug Currie provided), but that
might pull in to many dependencies for an initrd image.
Robert G. Jakabosky