[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: static linking with lua
- From: "Robert G. Jakabosky" <bobby@...>
- Date: Sat, 5 Mar 2011 01:30:47 -0800
On Saturday 05, Vasiliy G Tolstov wrote:
> On Sat, 2011-03-05 at 02:48 -0600, Jeff Pohlmeyer wrote:
> > On Sat, Mar 5, 2011 at 2:10 AM, Vasiliy G Tolstov wrote:
> > > I'm try to static link lua with my app
> > >
> > > Linking brings warning. How can I avoid this and what it mean for me if
> > > i want to build fully static binary, that can be running inside initrd
> > > with no libraries?
> > >
> > > warning: Using 'dlopen' in statically linked applications requires at
> > > runtime the shared libraries from the glibc version used for linking
> >
> > Does your application need to load any C modules at runtime?
> > If not, maybe you could build your own Lua lib without it.
> >
> > Something like this:
> >
> > cd /path/to/lua-5.1.4/src
> >
> > make clean ansi CFLAGS='-ULUA_DL_DLOPEN'
> >
> > cd /path/to/your/app
> >
> > cc -std=c99 -O0 -ggdb -static -static-libgcc -o embed embed.c \
> > -I/usr/include/lua5.1 -L/usr/lib64 /path/to/lua-5.1.4/src/liblua.a -lm
> > -lc
> >
> > (Note that I removed -llua5.1 and -ldl from the compiler command)
> >
> > - Jeff
>
> Thank You. But if my application can load shared libraries static
> linking is not allowed?
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.
You can statically compile some C modules into your program and preload them
(take a look at src/linit.c).
--
Robert G. Jakabosky