undefined reference 
Author Message
 undefined reference

Hi: When using math functions e.g, sin, exp, I get the message: "undefined
reference to ... "

althought in a header file i have

in file find_roots.h:
#include <assert.h>
#include <math.h>
#include <stdio.h>
..............
..............
etc.,

in another file I do my function definitions using some math functions.
When compiling the program I get the mentioned message. my question is :
Is there an instruction to compile the program so that the math fuctions
references are recognized automaticaly by the compier without using the -lm
flag when invoking gcc?

I'm using gcc version 2.96 20000731 (Red Hat Linux 7.2 2.96-108.7.2)

Thanks in advance for your help.
FM.
--
quidquid latet apparebit



Sun, 03 Apr 2005 16:22:44 GMT  
 undefined reference

Quote:
> Hi: When using math functions e.g, sin, exp, I get the message: "undefined
> reference to ... "

You'll want to add -lm to your command line. See the comp.lang.c FAQ.

--

| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste       W++ B OP+                     |
\----------------------------------------- Finland rules! ------------/
"The obvious mathematical breakthrough would be development of an easy way to
factor large prime numbers."  
   - Bill Gates



Sun, 03 Apr 2005 16:26:36 GMT  
 undefined reference

Quote:


>> Hi: When using math functions e.g, sin, exp, I get the message:
>> "undefined reference to ... "

> You'll want to add -lm to your command line. See the comp.lang.c FAQ.

Thanks for your anser, but where do I find the mentioned FAQ?...
--
quidquid latet apparebit


Sun, 03 Apr 2005 16:37:32 GMT  
 undefined reference
On Wed, 16 Oct 2002 02:37:32 -0600, Francisco Mendez said:

Quote:
>> You'll want to add -lm to your command line. See the comp.lang.c FAQ.

> Thanks for your anser, but where do I find the mentioned FAQ?...

It's posted here weekly. And several people have a URl for it in
their signatures. It's online here.
http://www.eskimo.com/~scs/C-faq/top.html
Bookmark it. Visit often :)

Cheers,
Dave.

--
           David Neary,
     E-Mail: bolsh at gimp dot org
CV: http://www.redbrick.dcu.ie/~bolsh/CV/CV.html



Sun, 03 Apr 2005 16:43:41 GMT  
 undefined reference

Quote:

> On Wed, 16 Oct 2002 02:37:32 -0600, Francisco Mendez said:
>>> You'll want to add -lm to your command line. See the comp.lang.c FAQ.

>> Thanks for your anser, but where do I find the mentioned FAQ?...

> It's posted here weekly. And several people have a URl for it in
> their signatures. It's online here.
> http://www.eskimo.com/~scs/C-faq/top.html
> Bookmark it. Visit often :)

> Cheers,
> Dave.

Thanks...      :)
FM.
--
quidquid latet apparebit


Sun, 03 Apr 2005 16:52:12 GMT  
 undefined reference

Quote:

> On Wed, 16 Oct 2002 02:37:32 -0600, Francisco Mendez said:
>>> You'll want to add -lm to your command line. See the comp.lang.c FAQ.

>> Thanks for your anser, but where do I find the mentioned FAQ?...

> It's posted here weekly. And several people have a URl for it in
> their signatures. It's online here.
> http://www.eskimo.com/~scs/C-faq/top.html
> Bookmark it. Visit often :)

> Cheers,
> Dave.

Hi:

After visiting the mentioned reference, chapter 13 Library functions, I
didn't find an answer to my question.   :(
--
quidquid latet apparebit



Sun, 03 Apr 2005 18:12:54 GMT  
 undefined reference

Quote:


>>On Wed, 16 Oct 2002 02:37:32 -0600, Francisco Mendez said:

>>>>You'll want to add -lm to your command line. See the comp.lang.c FAQ.

>>>Thanks for your anser, but where do I find the mentioned FAQ?...

>>It's posted here weekly. And several people have a URl for it in
>>their signatures. It's online here.
>>http://www.eskimo.com/~scs/C-faq/top.html
>>Bookmark it. Visit often :)

>>Cheers,
>>Dave.

> Hi:

> After visiting the mentioned reference, chapter 13 Library functions, I
> didn't find an answer to my question.   :(

Look under Section 14: Floating Point.  Specifically 14.3
(http://www.eskimo.com/~scs/C-faq/q14.3.html).  Yes, it may not be organized
they way *you* think it should be.  The best way to use it would be to
download a text copy and just search through it for what is relevant for you
(after reading it through fully atleast once).

-nrk.



Sun, 03 Apr 2005 19:26:13 GMT  
 undefined reference


Quote:
>On Wed, 16 Oct 2002 02:37:32 -0600, Francisco Mendez said:
>>> You'll want to add -lm to your command line. See the comp.lang.c FAQ.

>> Thanks for your anser, but where do I find the mentioned FAQ?...

>It's posted here weekly. And several people have a URl for it in
>their signatures. It's online here.
>http://www.eskimo.com/~scs/C-faq/top.html
>Bookmark it. Visit often :)

Or buy the book which has the full set of answers. Apparently there are
at least three of us here with a copy!

--

Add 'w' after my first name for correct e-mail address.

Bob Wightman



Wed, 06 Apr 2005 17:54:13 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. undefined reference to 'main'

2. Help with "Undefined reference" error

3. Undefined reference to function 'sqrt()'

4. undefined reference to `pow'

5. undefined reference to setsockopt, inet_addr, socket, htons

6. undefined reference to `_msize'

7. undefined reference to cos

8. Undefined Reference Error

9. undefined reference to

10. Help, undefined reference to 'sqrt'

11. Undefined Reference to main

12. undefined reference question

 

 
Powered by phpBB® Forum Software