home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / c / 13417 < prev    next >
Encoding:
Text File  |  1992-09-09  |  1.8 KB  |  48 lines

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