Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > compiler unable to find defn. of sin()

Reply
Thread Tools

compiler unable to find defn. of sin()

 
 
sudip
Guest
Posts: n/a
 
      06-24-2005
Dear All,
I'm having a nightmare compiling a small simple program on a Linux
Fedora core 2 platform...the program goes like this...

in file mathtest.c

#include <math.h>
#include <stdio.h>

int main(void)
{
printf("%s%d\n","The value of sin(3) is: ", sin(3));
return 0;
}

I'm compiling the above program by issuing the following command on
bash shell...

gcc -Wall -o mathtest mathtest.c

the compiler is throwing the following error

in function 'main':
:undefined reference to 'sin'

....and stops the compilation process..
I'm stuck up, and can't figure out the error..plz help

 
Reply With Quote
 
 
 
 
Artie Gold
Guest
Posts: n/a
 
      06-24-2005
sudip wrote:
> Dear All,
> I'm having a nightmare compiling a small simple program on a Linux
> Fedora core 2 platform...the program goes like this...
>
> in file mathtest.c
>
> #include <math.h>
> #include <stdio.h>
>
> int main(void)
> {
> printf("%s%d\n","The value of sin(3) is: ", sin(3));
> return 0;
> }
>
> I'm compiling the above program by issuing the following command on
> bash shell...
>
> gcc -Wall -o mathtest mathtest.c
>
> the compiler is throwing the following error
>
> in function 'main':
> :undefined reference to 'sin'
>
> ...and stops the compilation process..
> I'm stuck up, and can't figure out the error..plz help
>

This is a FAQ. Find it. Read it. It's not that hard. (And doing so will
serve you *very* well in the long run.)

HTH,
--ag
--
Artie Gold -- Austin, Texas
http://it-matters.blogspot.com (new post 12/5)
http://www.cafepress.com/goldsays
 
Reply With Quote
 
 
 
 
Martin Ambuhl
Guest
Posts: n/a
 
      06-24-2005
sudip wrote:

> the compiler is throwing the following error
>
> in function 'main':
> :undefined reference to 'sin'
>
> ...and stops the compilation process..
> I'm stuck up, and can't figure out the error..plz help
>


The best help (teach a man to fish): check the FAQ before posting.

The inferior help (give you the fish): what you'll find there. Does it
look familiar?
<http://www.eskimo.com/~scs/C-faq/q14.3.html>
Question 14.3

I'm trying to do some simple trig, and I am #including <math.h>, but I
keep getting ``undefined: sin'' compilation errors.

Make sure you're actually linking with the math library. For instance,
under Unix, you usually need to use the -lm option, at the end of the
command line, when compiling/linking. See also questions 13.25 and 13.26.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to exclude action of Find::Find::find in subdirectories withknown names? vdvorkin Perl Misc 3 02-14-2011 05:28 AM
How to exclude action of Find::Find::find in subdirectories withknown names? vdvorkin Perl Misc 0 02-10-2011 05:18 PM
eclispe WTP kann Webapp unter JBoss nicht starten wg. "Unable to find a javac compiler;" f.mayer@web.de Java 1 01-19-2007 09:58 PM
Find.find does not find orphaned links? Wybo Dekker Ruby 1 11-15-2005 02:50 PM
Unable to see machines on the ethernet; Unable to find printers =?Utf-8?B?Sm9obiBN?= Wireless Networking 1 06-07-2005 03:32 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57