Re: [AD] static link

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Sun, 2004-03-14 at 23:39, Eric Botcazou wrote:
> > > gcc -static -DALLEGRO_STATICLINK -o demo demo.c `allegro-config
> > > --static`
> >
> > /usr/local/lib/liballeg.a(umodules.o)(.text+0x1d9): In function 
> `_unix_load_modules':
> > : warning: Using 'dlopen' in statically linked applications requires at
> > : runtime the shared libraries from the glibc version used for linking
> 
> I don't get them on my system (binutils 2.14).  Could you run 'ldd' on the 
> executable?

Well, not surprisingly:

> ldd demo
        not a dynamic executable

ld --version says 2.14.90.0.7 here. gcc is 3.3.3.

Oh, and if I disable modules, the dlopen warning from last time
disappears, but instead I get some errors:

/usr/lib/libasound.a(simple.lo)(.text+0x1eb8): In function `.L384':
: undefined reference to `sqrt'
/usr/lib/libasound.a(dlmisc.o)(.text+0xa8): In function
`snd_dlsym_verify':
: undefined reference to `dlsym'
/usr/lib/libasound.a(dlmisc.o)(.text+0xc): In function `snd_dlopen':
: undefined reference to `dlopen'
/usr/lib/libasound.a(dlmisc.o)(.text+0x2f): In function `snd_dlclose':
: undefined reference to `dlclose'
/usr/lib/libasound.a(dlmisc.o)(.text+0x13c): In function `snd_dlsym':
: undefined reference to `dlsym'
collect2: ld returned 1 exit status

The reason is clear:
> allegro-config --static
-L/usr/local/lib -L/usr/X11R6/lib -lalleg -lm -lpthread -lXxf86dga
-lXxf86dga -lXxf86vm -lXext -lX11 -L/usr/lib -lesd -laudiofile -lm
-lasound

Without -static, -lasound doesn't require -lm and -ld. If I manually add
them at the end, it compiles again, with the same warnings. Again, the
resulting executable works fine - but it displays
ALSA lib pcm.c:1917:(snd_pcm_open_conf) symbol _snd_pcm_plug_open is not
defined inside (null)
and then uses OSS.

> 
> > For me, the resulting executable is huge, but still, it works. I guess I
> > have that "shared libraries from the glibc version used for linking"
> > installed - so that explains why it works. You probably don't have them,
> > so it just aborts. (Just a guess.)
> 
> It crashes on my system with:
> 
> Core was generated by `./demo'.
> Program terminated with signal 11, Segmentation fault.
> #0  0x0809650c in _xwin_signal_handler ()
> (gdb) bt
> #0  0x0809650c in _xwin_signal_handler ()
> #1  0x08096500 in stretch_sprite ()
> #2  <signal handler called>
> #3  0x0809650c in _xwin_signal_handler ()
> #4  0x08096500 in stretch_sprite ()
> #5  <signal handler called>
> #6  0x0809650c in _xwin_signal_handler ()
> #7  0x08096500 in stretch_sprite ()
> #8  <signal handler called>
> ...
> 
> On the other hand, linking against Allegro-static but without -static works.
> 

Well, it doesn't crash for me. And without -static, everything works
fine of course.. static linking (against Allegro only) is what I often
use. The mentioned function must somehow be special.. maybe for security
or some other reasons they are never static inlined, not even with
-static?

> > I'm still puzzled why I could use -static in the past and even 2 days
> > ago, and now get these warnings. I even remember sending a -static
> > executable to someone once, to test binary compatibility of Allegro in
> > linux, and it worked. Maybe someone else here can shed some light on the
> > issue.
> 
> Pretty weird indeed.
> 

Debian might have upgraded gcc/binutils in between.. I have apt-watch
running lately and let it upgrade around as it likes :)
Anyway, I don't think it matters much if -static doesn't work

-- 
Elias Pschernig <elias@xxxxxxxxxx>





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/