[Discuss] Compiling a binary
Hans Oeste
hoeste at shaw.ca
Tue Sep 26 20:43:33 PDT 2006
OK, I'm stumped.
I've messed with the Makefile that ./configure produces and it's not working
Is there a parameter that I can pass to ./configure to make it produce a
static fully linked binary?
I have tried sudo ./configure LDFLAGS=-r
And get an error that the C compiler cannot create executeables
Huh?
Hans
-------Original Message-------
From: noel at natnix.com
Date: 09/21/06 15:47:14
To: discuss at vlug.org
Subject: Re: [Discuss] Compiling a binary
You may want to link some dynamic libraries statically, but keep the
standard system libraries (like libc) dyncamically.
You can use ld -r to statically link a bunch of object files and
dynamic .so files to product anoter linkable static .o file. Here's
an example that statically links in -lm, but still uses a dynamic libc:
$ cat sin.c
#include <math.h>
#include <stdio.h>
int main() { printf("sin(1)=%f\n", sin(1)); }
Statically combine sin.o and -lm into sin_lm.o
$ cc -c sin.c
$ ld -r -o sin+lm.o sin.o -lm
Produce final execuatble liked with dynamic libc
$ cc -o sin+lm sin+lm.o
$ ldd sin+lm
libc.so.6 => /lib/tls/libc.so.6 (0x4001f000)
/lib/ld-linux.so.2 (0x40000000)
--Noel
On Wed, Sep 20, 2006 at 10:43:34PM -0700, Hans Oeste wrote:
> I want to take a program that is currently being compiled to use the
> libraries currently installed i.e. linking to them, to have the necessary
> libraries compiled into the binary so I can run the program on a computer
> that doesn't have those libraries installed. Can some-one point me in the
> correct direction for the endeavor?
>
> Hans
> _______________________________________________
> Discuss mailing list
> Discuss at vlug.org
> http://ladybug.vlug.org/cgi-bin/mailman/listinfo/discuss
_______________________________________________
Discuss mailing list
Discuss at vlug.org
http://ladybug.vlug.org/cgi-bin/mailman/listinfo/discuss
.
More information about the Discuss
mailing list