Q: Red Hat 5.1 Linux - 'C' math problem

Q: Red Hat 5.1 Linux - 'C' math problem

Post by W. John Gammag » Sat, 03 Oct 1998 04:00:00



The following simple test program produces the attached "undefined
reference to `sin'" diagnostic message.  I am using Red Hat 5.1 Linux.
This trig function is the only difficulty that I am experiencing in my
development.

It looks to me like I am either required to include file include an
include file in addition to the <math.h>.  However, this is not required
on other UNIX systems.  The man page for 'sin' does not specify an
include file in addition to the <math.h> file which I have included.

It certainly looks like a prototype issue.  Am I missing something
obvious here?  Your comments by e-mail are appreciated.

Regards,  W. John Gammage


--------=[ begin code and diagnostic excerpt here ]=--------

jgammage /Users/jgammage/Programs/Hack ! ;) make math
cc     math.c   -o math

/tmp/cca003491.o: In function `main':
/tmp/cca003491.o(.text+0xe): undefined reference to `sin'
make: *** [math] Error 1

Test program:

#include <math.h>
double   d_Scale;
main () {
    d_Scale  = sin( M_PI );

Quote:}

--------=[ end code and diagnostic excerpt here ]=--------
 
 
 

Q: Red Hat 5.1 Linux - 'C' math problem

Post by Aaron Cra » Sat, 03 Oct 1998 04:00:00




Quote:> jgammage /Users/jgammage/Programs/Hack ! ;) make math
> cc     math.c   -o math

> /tmp/cca003491.o: In function `main':
> /tmp/cca003491.o(.text+0xe): undefined reference to `sin'
> make: *** [math] Error 1

Use `cc -o math math.c -lm'.  You have to link the math library into your
program (-lm) and the `-lm' must come at the end of the command line (or at
least, after all the object files that need symbols it defines).

BTW, this is in the comp.lang.c FAQ list, `if only you had thought to look
there'; try <URL:http://www.eskimo.com/~scs/C-faq/top.html>.

--


 
 
 

Q: Red Hat 5.1 Linux - 'C' math problem

Post by Thomas Glanzman » Sat, 03 Oct 1998 04:00:00


try to use the option -lm (linking with math lib).
next time please refer the man page of math lib (man math)

        greetings tg


> The following simple test program produces the attached "undefined
> reference to `sin'" diagnostic message.  I am using Red Hat 5.1 Linux.
> This trig function is the only difficulty that I am experiencing in my
> development.

> It looks to me like I am either required to include file include an
> include file in addition to the <math.h>.  However, this is not required
> on other UNIX systems.  The man page for 'sin' does not specify an
> include file in addition to the <math.h> file which I have included.

> It certainly looks like a prototype issue.  Am I missing something
> obvious here?  Your comments by e-mail are appreciated.

> Regards,  W. John Gammage


> --------=[ begin code and diagnostic excerpt here ]=--------

> jgammage /Users/jgammage/Programs/Hack ! ;) make math
> cc     math.c   -o math

> /tmp/cca003491.o: In function `main':
> /tmp/cca003491.o(.text+0xe): undefined reference to `sin'
> make: *** [math] Error 1

> Test program:

> #include <math.h>
> double   d_Scale;
> main () {
>     d_Scale  = sin( M_PI );
> }

> --------=[ end code and diagnostic excerpt here ]=--------

 
 
 

1. Newbie Problems - Red Hat 5.1 can't find HD

I have lurked for a bit, and am hoping this group can help me with a
basic problem.  I am a total
newbie with Linux, but have a PC on a home LAN (3 PC's) that I would
like to dedicate to Linux.

I am attempting to load Red Hat 5.1 onto a Compaq Presario 486 w/12 MB
Memory and a
212 MB Hard Disk.  I am attempting to install from a CD-ROM, but neither
Disk Druid or FDISK
can "find" my hard drive during the installation process.

I was feeling pretty good (as a newbie) after installing Red Hat on two
other machines,
(dual boot w/Win 98) but they were able to boot directly from the CD -
this machine cannot.

The entire HD will be dedicated to Linux.  I have tried recreating the
boot disk several
times using RAWRITE, and have killed the HD using fdisk and fdisk /mbr.
The HD works fine,
as I was able to copy files in an attempt to install via hard drive (no
success either).  Right now the HD is unpartitioned.

The install process tells me that there are no drives available because
I haven't identified a SCSI adapter, but none are present.  I've been
trying to read all the newsgroups, as well as the reams of information
on Linux, but it would sure help to have a dedicated machine I could try
all of this neat stuff out on.

I hope this question isn't too stupid......Any help would be
appreciated.

2. Lucent Winmodem drivers question

3. Red Hat 5.1 installation won't boot off Hard Drive?

4. Help, various needs

5. Red Hat 5.1 can't see my hard disk !!!

6. comp.os.linux.security biweekly FAQ pointer

7. NEWBIE: I can't build kermit on Red Hat 5.1

8. PPP connection

9. Red Hat 5.1 can't see me hard disk !!!

10. Can't compiler java program in Red Hat 5.1!

11. What's difference between Red Hat 5.0 and 5.1?

12. Red Hat 5.1 won't mount CD

13. Red Hat 5.1 - bootloader won't install