[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: static linking

From: Rob Browning
Subject: Re: static linking
Date: Thu, 05 Feb 2004 20:23:06 -0600
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

[cc'ing guile-devel too]

"Rouben Rostamian" <address@hidden> writes:

> However, I wish to link against Guile's static libraries.
> To that end, I do:
>    gcc try.c libguile.a libguile-ltdl.a -lcrypt -ldl -lm

> which also compiles successfully and produces an executable a.out.
> The trouble is, a.out does not run:
>    linux> ./a.out 
>    Segmentation fault (core dumped)

First question -- what system are you running on and where did your
guile libs come from?  i.e. Debian unstable, Debian stable, home
built, some other dist, etc.

For me, doing the same compile, but using the installed libs via
-static won't link at all.

  $ gcc -static try.c -lguile -lguile-ltdl -lcrypt -ldl -lm
  ...(many link errors)...
  : undefined reference to `qt_block'
  (.text+0xa24):In function `coop_yield':
  : undefined reference to `qt_block'

if I use $(guile-config link), I get closer:

  gcc -static try.c $(guile-config compile) $(guile-config link)

but I still have undefined ltdl symbols.  This looks like a missing
link option on our part, i.e. guile-config link says:

  -lguile -lguile-ltdl -lqthreads -lpthread -lcrypt -lm

but actually -lguile and -lguile-ltdl are mutually dependent, so for
static linking we really need

  -lguile -lguile-ltdl -lguile -lqthreads -lpthread -lcrypt -lm

this gets things to compile, and *then* I can reproduce your segfault.

  $ gcc -g -O2 -Wall -Werror -static try.c -lguile -lguile-ltdl -lguile
  -lqthreads -lpthread -lcrypt -lm -ldl
  ... (many lines of warnings like this)...
  : warning: Using 'setservent' in statically linked applications
  requires at runtime the shared libraries from the glibc version used
  for linking
  $ ./a.out
  Segmentation fault
  $ gdb ./a.out 
  GNU gdb 6.0-debian
  (gdb) run
  Starting program: /home/rlb/tmp/a.out 
  Program received signal SIGSEGV, Segmentation fault.
  0x00000000 in ?? ()

Not too friendly.

So I don't know what's going on yet, but at least it's reproducable.
Also, I'm running Debian unstable, but someone else who was running
Debian testing couldn't reproduce the problem.

Rob Browning
rlb and; previously
GPG starting 2002-11-03 = 14DD 432F AE39 534D B592  F9A0 25C8 D377 8C7E 73A4

reply via email to

[Prev in Thread] Current Thread [Next in Thread]