public inbox for gsl-discuss@sourceware.org
 help / color / mirror / Atom feed
* Re: Re: undefined reference
@ 2003-09-22 18:44 Cheng Xing
  2003-09-22 18:52 ` Martin Jansche
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Cheng Xing @ 2003-09-22 18:44 UTC (permalink / raw)
  To: gsl-discuss

Well, I input gsl-config --lib, and get
-L/usr/local/lib -lgsl -lgslcblas -lm
So is that ok to compile with 'gcc filename -lgsl -lgslcblas -lm'?
I did compile successfully this time, but got another warning message 
when run the file a.out. It said:
a.out: error while loading shared libraries: libgsl.so.0 : cannot open 
shared object file: No such file or directory.
But I did find this file in my usr/local/lib

-Cheng


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

* Re: Re: undefined reference
  2003-09-22 18:44 Re: undefined reference Cheng Xing
@ 2003-09-22 18:52 ` Martin Jansche
  2003-09-22 18:53 ` Jeff Spirko
  2003-09-22 18:57 ` Achim Gädke
  2 siblings, 0 replies; 7+ messages in thread
From: Martin Jansche @ 2003-09-22 18:52 UTC (permalink / raw)
  To: gsl-discuss

On Mon, 22 Sep 2003, Cheng Xing wrote:

> Well, I input gsl-config --lib, and get
> -L/usr/local/lib -lgsl -lgslcblas -lm

So use precisely that.

> So is that ok to compile with 'gcc filename -lgsl -lgslcblas -lm'?

You just proved to yourself that it's not OK.  You probably need a -L
or -R option for your linker.  Why don't you use `gsl-config --libs`
or $(gsl-config --libs) on your command line?  As in "gcc $(gsl-config
 --cflags) myfile.c $(gsl-config --libs)".

> I did compile successfully this time, but got another warning message
> when run the file a.out. It said:
> a.out: error while loading shared libraries: libgsl.so.0 : cannot open
> shared object file: No such file or directory.
> But I did find this file in my usr/local/lib

And that's your dynamic linker telling you that /usr/local/lib is not
in your dynamic library path.  Read up on configuring /etc/ld.so.conf
or setting LD_LIBRARY_PATH.

- mj

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

* Re: Re: undefined reference
  2003-09-22 18:44 Re: undefined reference Cheng Xing
  2003-09-22 18:52 ` Martin Jansche
@ 2003-09-22 18:53 ` Jeff Spirko
  2003-09-22 18:57 ` Achim Gädke
  2 siblings, 0 replies; 7+ messages in thread
From: Jeff Spirko @ 2003-09-22 18:53 UTC (permalink / raw)
  To: Cheng Xing; +Cc: gsl-discuss

On Mon, Sep 22, 2003 at 07:43:45PM +0100, Cheng Xing wrote:
> Well, I input gsl-config --lib, and get
> -L/usr/local/lib -lgsl -lgslcblas -lm
> So is that ok to compile with 'gcc filename -lgsl -lgslcblas -lm'?
> I did compile successfully this time, but got another warning message 
> when run the file a.out. It said:
> a.out: error while loading shared libraries: libgsl.so.0 : cannot open 
> shared object file: No such file or directory.
> But I did find this file in my usr/local/lib

You can either add /usr/local/lib to the list of directories that
are searched for libraries, by adding it to /etc/ld.so.conf and
running (as root) ldconfig.  Or, you can run your program with
  LD_LIBRARY_PATH=/usr/local/lib a.out


-- 
Jeff Spirko   spirko@lehigh.edu   spirko@yahoo.com   WD3V   |=>

                      /* - * - * - * - * - * - * - *\
Check out my Blog at |  http://spirko.blogspot.com/  |
                      \* - * - * - * - * - * - * - */

The study of non-linear physics is like the study of non-elephant biology.

All theoretical chemistry is really physics;
and all theoretical chemists know it. -- Richard P. Feynman 

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

* Re: undefined reference
  2003-09-22 18:44 Re: undefined reference Cheng Xing
  2003-09-22 18:52 ` Martin Jansche
  2003-09-22 18:53 ` Jeff Spirko
@ 2003-09-22 18:57 ` Achim Gädke
  2 siblings, 0 replies; 7+ messages in thread
From: Achim Gädke @ 2003-09-22 18:57 UTC (permalink / raw)
  To: Cheng Xing; +Cc: gsl-discuss

Cheng Xing wrote:

> Well, I input gsl-config --lib, and get
> -L/usr/local/lib -lgsl -lgslcblas -lm
> So is that ok to compile with 'gcc filename -lgsl -lgslcblas -lm'?
> I did compile successfully this time, but got another warning message 
> when run the file a.out. It said:
> a.out: error while loading shared libraries: libgsl.so.0 : cannot open 
> shared object file: No such file or directory.
> But I did find this file in my usr/local/lib
>
> -Cheng


Ok, now add /usr/local/lib to the environment variable LD_LIBRARY_PATH, 
for bash it is

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

In order to add the additional library search path to the binary use the 
flag while compiling:

-Wl,-rpath=/usr/local/lib

Yours, Achim

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

* Re: undefined reference
  2003-09-22 18:13 cx101
  2003-09-22 18:17 ` Martin Jansche
@ 2003-09-23  9:06 ` Brian Gough
  1 sibling, 0 replies; 7+ messages in thread
From: Brian Gough @ 2003-09-23  9:06 UTC (permalink / raw)
  To: cx101; +Cc: gsl-discuss

cx101 writes:
 > Hi guys,
 > 
 > I never compiled a programme successfully after I installed GSL 1.4. I 
 > was always told undefined reference to some head files. I even got the
 > warning message after run the following simple programme from the manual
 > of GSL:
 > 

The commands needed to compile the example program are given in the
same chapter of the manual.

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

* Re: undefined reference
  2003-09-22 18:13 cx101
@ 2003-09-22 18:17 ` Martin Jansche
  2003-09-23  9:06 ` Brian Gough
  1 sibling, 0 replies; 7+ messages in thread
From: Martin Jansche @ 2003-09-22 18:17 UTC (permalink / raw)
  To: gsl-discuss

On Mon, 22 Sep 2003, cx101 wrote:

> When compiling, I was told:
> /tmp/cc807SzQ.o(.text+0x28): In function 'main':
> :undefined reference to 'gsl_sf_bessel_J0'
> collect2: ld return 1 exit status

It's the linker that produced the error message.  You need to tell us
the exact command line you used to invoke the compiler.  My guess is
that you forgot to include $(gsl-config --libs) (ksh syntax, use
backquotes in sh) for the linking step.

- martin

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

* undefined reference
@ 2003-09-22 18:13 cx101
  2003-09-22 18:17 ` Martin Jansche
  2003-09-23  9:06 ` Brian Gough
  0 siblings, 2 replies; 7+ messages in thread
From: cx101 @ 2003-09-22 18:13 UTC (permalink / raw)
  To: gsl-discuss

Hi guys,

I never compiled a programme successfully after I installed GSL 1.4. I 
was always told undefined reference to some head files. I even got the
warning message after run the following simple programme from the manual
of GSL:

#include <stdio.h>
#include <gsl/gsl_sf_bessel.h>

int main(void)
{
	double x=5.0;
	double y = gsl_sf_bessel_J0 (x);
	printf("J0(%g) = %.18e\n", x, y);
	return 0;
}

When compiling, I was told:
/tmp/cc807SzQ.o(.text+0x28): In function 'main':
:undefined reference to 'gsl_sf_bessel_J0'
collect2: ld return 1 exit status

My gcc is 3.2.3, system is Mandrake 9.1.
I know it is a very stupid question. I am a rookie for linux.

Cheng

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

end of thread, other threads:[~2003-09-23  9:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-22 18:44 Re: undefined reference Cheng Xing
2003-09-22 18:52 ` Martin Jansche
2003-09-22 18:53 ` Jeff Spirko
2003-09-22 18:57 ` Achim Gädke
  -- strict thread matches above, loose matches on Subject: below --
2003-09-22 18:13 cx101
2003-09-22 18:17 ` Martin Jansche
2003-09-23  9:06 ` Brian Gough

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