public inbox for gsl-discuss@sourceware.org
 help / color / mirror / Atom feed
* Re: using static libraries
  2001-12-19 13:20   ` Daniel Rohe
@ 2001-12-19 13:20     ` Brian Gough
  0 siblings, 0 replies; 5+ messages in thread
From: Brian Gough @ 2001-12-19 13:20 UTC (permalink / raw)
  To: rohe; +Cc: gsl list

Daniel Rohe writes:
 >  >g++ -static -lgsl -lgslcblas gsl_test.c -o gsl_test.out
 > /usr/tmp/ccpuyfqp.o: In function `main':
 > /usr/tmp/ccpuyfqp.o(.text+0x11): undefined reference to `gsl_isinf'
 > collect2: ld returned 1 exit status
 > 

The "-lgsl -lgslcblas" needs to be at the end of the command line

regards
Brian

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

* using static libraries
@ 2001-12-19 13:20 Daniel Rohe
  2001-12-19 13:20 ` Achim Gaedke
  2001-12-19 13:20 ` Dirk Eddelbuettel
  0 siblings, 2 replies; 5+ messages in thread
From: Daniel Rohe @ 2001-12-19 13:20 UTC (permalink / raw)
  To: gsl list

I'd like to use the static version of gsl. what do I need to specify during compilation to 
do this?

Daniel



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

* Re: using static libraries
  2001-12-19 13:20 ` Achim Gaedke
@ 2001-12-19 13:20   ` Daniel Rohe
  2001-12-19 13:20     ` Brian Gough
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Rohe @ 2001-12-19 13:20 UTC (permalink / raw)
  To: Achim Gaedke; +Cc: gsl list

thanks for the reply. following your suggestion I tried the -static option:

source:

#include <gsl/gsl_math.h>

int main()
{
   gsl_isinf(1.0);
}


result:

 >g++ -static -lgsl -lgslcblas gsl_test.c -o gsl_test.out
/usr/tmp/ccpuyfqp.o: In function `main':
/usr/tmp/ccpuyfqp.o(.text+0x11): undefined reference to `gsl_isinf'
collect2: ld returned 1 exit status

I'm pretty sure I'm making some sort of silly mistake again, but I can't see it.


without -static everything seems to be fine:

 >g++ -lgsl -lgslcblas gsl_test.c -o gsl_test.out
 >./gsl_test.out
 >

??

Achim Gaedke wrote:

> Daniel Rohe schrieb:
> 
>>I'd like to use the static version of gsl. what do I need to specify during compilation to
>>do this?
>>
>>Daniel
>>
> 
> Hi Daniel!
> 
> This is the normal dynamic way (here a test application gsl_brent)
> 
> make gsl_brent
> cc -c -I/opt/gsl-1.0/include -o gsl_brent.o gsl_brent.c
> cc gsl_brent.o -o gsl_brent -L/opt/gsl-1.0/lib -lgsl -lgslcblas
> 
> The Makefile is (for gnu make):
> 
> GSL_PREFIX := $(shell gsl-config --prefix)
> 
> gsl_brent.o:	gsl_brent.c
> 	$(CC) -c -I$(GSL_PREFIX)/include -o $@ $<
> 
> gsl_brent:	gsl_brent.o
> 	$(CC) $< -o $@ -L$(GSL_PREFIX)/lib -lgsl -lgslcblas
> 
> (Do not forget to correct the tab-spaces, if using these lines)
> 
> To check, what is linked dynamically, use ldd:
> 
> ldd ./gsl_brent
>         libgsl.so.0 => /opt/gsl-1.0/lib/libgsl.so.0 (0x40017000)
>         libgslcblas.so.0 => /opt/gsl-1.0/lib/libgslcblas.so.0
> (0x40180000)
>         libc.so.6 => /lib/libc.so.6 (0x401c0000)
>         libm.so.6 => /lib/libm.so.6 (0x402f5000)
>         libgcc_s.so.1 => /opt/gcc-3.0.2/lib/libgcc_s.so.1 (0x40318000)
>         /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
> 
> This was done on a linux system with gcc-3.0.2.
> 
> You can avoid dynamic linking generally by using -static, or in
> particular to have static gsl-linking:
> 
> cc gsl_brent.o -o gsl_brent /opt/gsl-1.0/lib/libgsl.a
> /opt/gsl-1.0/lib/libgslcblas.a
> 
> This should be the Makefile rule:
> 
> gsl_brent:	gsl_brent.o
> 	$(CC) $< -o $@ $(GSL_PREFIX)/lib/libgsl.a
> $(GSL_PREFIX)/lib/libgslcblas.a
> 
> Make executes:
> 
> cc gsl_brent.o -o gsl_brent /opt/gsl-1.0/lib/libgsl.a
> /opt/gsl-1.0/lib/libgslcblas.a
> 
> now ldd results:
> 
> ldd ./gsl_brent
>         libc.so.6 => /lib/libc.so.6 (0x40024000)
>         /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
> 
> 
> If you like to know more details, please ask.
> 
> 


-- 
Daniel Rohe
Institut fuer Theoretische Physik
Lehrstuhl C
RWTH Aachen
52056 Aachen

Tel.: 0241 8028392

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

* Re: using static libraries
  2001-12-19 13:20 using static libraries Daniel Rohe
@ 2001-12-19 13:20 ` Achim Gaedke
  2001-12-19 13:20   ` Daniel Rohe
  2001-12-19 13:20 ` Dirk Eddelbuettel
  1 sibling, 1 reply; 5+ messages in thread
From: Achim Gaedke @ 2001-12-19 13:20 UTC (permalink / raw)
  To: rohe; +Cc: gsl list

Daniel Rohe schrieb:
> 
> I'd like to use the static version of gsl. what do I need to specify during compilation to
> do this?
> 
> Daniel

Hi Daniel!

This is the normal dynamic way (here a test application gsl_brent)

make gsl_brent
cc -c -I/opt/gsl-1.0/include -o gsl_brent.o gsl_brent.c
cc gsl_brent.o -o gsl_brent -L/opt/gsl-1.0/lib -lgsl -lgslcblas

The Makefile is (for gnu make):

GSL_PREFIX := $(shell gsl-config --prefix)

gsl_brent.o:	gsl_brent.c
	$(CC) -c -I$(GSL_PREFIX)/include -o $@ $<

gsl_brent:	gsl_brent.o
	$(CC) $< -o $@ -L$(GSL_PREFIX)/lib -lgsl -lgslcblas

(Do not forget to correct the tab-spaces, if using these lines)

To check, what is linked dynamically, use ldd:

ldd ./gsl_brent
        libgsl.so.0 => /opt/gsl-1.0/lib/libgsl.so.0 (0x40017000)
        libgslcblas.so.0 => /opt/gsl-1.0/lib/libgslcblas.so.0
(0x40180000)
        libc.so.6 => /lib/libc.so.6 (0x401c0000)
        libm.so.6 => /lib/libm.so.6 (0x402f5000)
        libgcc_s.so.1 => /opt/gcc-3.0.2/lib/libgcc_s.so.1 (0x40318000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)

This was done on a linux system with gcc-3.0.2.

You can avoid dynamic linking generally by using -static, or in
particular to have static gsl-linking:

cc gsl_brent.o -o gsl_brent /opt/gsl-1.0/lib/libgsl.a
/opt/gsl-1.0/lib/libgslcblas.a

This should be the Makefile rule:

gsl_brent:	gsl_brent.o
	$(CC) $< -o $@ $(GSL_PREFIX)/lib/libgsl.a
$(GSL_PREFIX)/lib/libgslcblas.a

Make executes:

cc gsl_brent.o -o gsl_brent /opt/gsl-1.0/lib/libgsl.a
/opt/gsl-1.0/lib/libgslcblas.a

now ldd results:

ldd ./gsl_brent
        libc.so.6 => /lib/libc.so.6 (0x40024000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)


If you like to know more details, please ask.

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

* Re: using static libraries
  2001-12-19 13:20 using static libraries Daniel Rohe
  2001-12-19 13:20 ` Achim Gaedke
@ 2001-12-19 13:20 ` Dirk Eddelbuettel
  1 sibling, 0 replies; 5+ messages in thread
From: Dirk Eddelbuettel @ 2001-12-19 13:20 UTC (permalink / raw)
  To: Daniel Rohe; +Cc: gsl list

On Sun, Nov 04, 2001 at 05:02:23PM +0100, Daniel Rohe wrote:
> I'd like to use the static version of gsl. what do I need to specify during compilation to 
> do this?

edd@homebud:~/debian/gsl-1.0> ./configure --help | grep static
  --enable-static[=PKGS]  build static libraries [default=yes]

Nothing, I guess.

Dirk

-- 
Three out of two people have difficulties with fractions.

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

end of thread, other threads:[~2001-12-19 13:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-19 13:20 using static libraries Daniel Rohe
2001-12-19 13:20 ` Achim Gaedke
2001-12-19 13:20   ` Daniel Rohe
2001-12-19 13:20     ` Brian Gough
2001-12-19 13:20 ` Dirk Eddelbuettel

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