home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!stanford.edu!leland.Stanford.EDU!sigmond
- From: sigmond@leland.Stanford.EDU (Steve Sigmond)
- Subject: Help! <math.h> strangeness
- Message-ID: <1992Sep10.003742.5413@leland.Stanford.EDU>
- Sender: news@leland.Stanford.EDU (Mr News)
- Organization: DSG, Stanford University, CA 94305, USA
- References: <1992Sep9.154828.15038@Cadence.COM>
- Distribution: usa
- Date: Thu, 10 Sep 92 00:37:42 GMT
- Lines: 35
-
-
- I have been trying to figure out why the following program won't work:
-
- #include <math.h>
-
- main()
- {
- printf("%f\n",sqrt(3.0));
- }
-
- When I type "cc test.c" I get the error message "ld: undefined symbol:
- _sqrt". I get a similar error message when I try to use other functions
- defined in math.h, such as cos, tan, log, and so forth. What's
- strange about this is that I can call functions defined in the other
- libraries (stdio.h, string.h, etc.) I can also access constants defined
- in math.h such as M_E without any problems. But whenever I call a function
- from math.h, I get this error. I looked at usr/include, and math.h doesn't
- appear to be corrupted or missing or otherwise abnormal.
-
- I have tried compiling this program on four different unix systems:
- BSD 4.2, Ultrix, SunOS, and AT&T System V. I always get the same
- "undefined symbol" message. I can get it to work on my Macintosh using
- THINK C.
-
- Any ideas as to what I might be doing wrong? It looks like the loader
- thinks I haven't defined the sqrt() function, but I thought the
- #include would deal with that.
-
- Apologies if this is a FAQ or if I'm being brain-dead without realizing it.
- Thanks in advance!
- --
- E-mail: sigmond@leland.stanford.edu steve@ast1.spa.umn.edu
- sigmond@mensch.stanford.edu sigmond@cra.canon.com
- 70640.2661@compuserve.com
- <insert creativity here>
-