unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* static linking
@ 2004-01-15  5:50 Rouben Rostamian
  2004-02-06  2:23 ` Rob Browning
  0 siblings, 1 reply; 4+ messages in thread
From: Rouben Rostamian @ 2004-01-15  5:50 UTC (permalink / raw)


I am having trouble compiling and linking a C program with Guile
libraries on Linux.  I hope to get useful suggestions from you folks.

The C program is shown below in its entirety.  It is extracted from
Guile's documentation:

/* -------- try.c ------------------- */

#include <libguile.h>

static void inner_main(void *closure, int argc, char **argv)
{
	scm_shell(argc, argv);
}

int main(int argc, char **argv)
{
	scm_boot_guile(argc, argv, inner_main, 0);
	return 0;
}

/* ---------------------------------- */


Compiling this with:

   gcc try.c -lguile

produces a dynamically linked executable a.out.  It compiles
and runs just fine.

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)

I tried playing with various compilation flags (-static -g -O0)
unsuccessfully.

If you have hints about compiling with guile's static libraries
I would be interest to know.

System info:

   Linux kernel: 2.4.21
   gcc: 3.3.1
   guile: 1.6.4


-- 
Rouben Rostamian


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: static linking
  2004-01-15  5:50 static linking Rouben Rostamian
@ 2004-02-06  2:23 ` Rob Browning
  2004-02-12 23:39   ` Marius Vollmer
  0 siblings, 1 reply; 4+ messages in thread
From: Rob Browning @ 2004-02-06  2:23 UTC (permalink / raw)
  Cc: guile-user, guile-devel

[cc'ing guile-devel too]

"Rouben Rostamian" <rostamian@umbc.edu> 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'
  /usr/lib/gcc-lib/i486-linux/3.3.3/../../../libguile.a(threads.o)
  (.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 @defaultvalue.org and @debian.org; previously @cs.utexas.edu
GPG starting 2002-11-03 = 14DD 432F AE39 534D B592  F9A0 25C8 D377 8C7E 73A4


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: static linking
@ 2004-02-06  3:55 Rouben Rostamian
  0 siblings, 0 replies; 4+ messages in thread
From: Rouben Rostamian @ 2004-02-06  3:55 UTC (permalink / raw)
  Cc: guile-user

Thank you, Rob, for responding to my message regarding static linking
with libguile.  Yours is the only response I have received to that
query.  The message was posted about 20 days ago, so I had given up
hope of getting any sort of response.

You asked:

> 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.

I compiled it myself from the 1.6.4 distribution.  My system's
specs were in the original message.  I will reproduce it here:

   Linux kernel: 2.4.21
   gcc: 3.3.1
   guile: 1.6.4

Additionally, the system is SuSE 9.0 and runs on glibc 2.3.2.

If you figure out how to do static linking with libguile, I would really
appreciate it if you would let me know.  In particular, since you have
cc-ed your message to guile-devel, if you get useful feedback there,
please let me know since I do not subscribe to guile-devel.

Rouben

-- 
Rouben Rostamian
v


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: static linking
  2004-02-06  2:23 ` Rob Browning
@ 2004-02-12 23:39   ` Marius Vollmer
  0 siblings, 0 replies; 4+ messages in thread
From: Marius Vollmer @ 2004-02-12 23:39 UTC (permalink / raw)
  Cc: guile-user, guile-devel

Rob Browning <rlb@defaultvalue.org> writes:

> So I don't know what's going on yet, but at least it's reproducable.

I can't reproduce it.  The resulting statically linked a.out cannot
load shared libraries (so that for example libguilereadline doesn't
work), tho.  No segfaults happen, howevers.

    $ ldd a.out
            not a dynamic executable

    $ ./a.out
    ERROR: In procedure dynamic-link:
    ERROR: file: "libguilereadline-v-12", message: "/usr/local/lib/libguilereadline-v-12.a: invalid ELF header"

    $ ./a.out -q
    guile>

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-02-12 23:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-15  5:50 static linking Rouben Rostamian
2004-02-06  2:23 ` Rob Browning
2004-02-12 23:39   ` Marius Vollmer
  -- strict thread matches above, loose matches on Subject: below --
2004-02-06  3:55 Rouben Rostamian

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).