home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / os / linux / 25475 < prev    next >
Encoding:
Text File  |  1993-01-25  |  2.0 KB  |  58 lines

  1. Newsgroups: comp.os.linux
  2. Path: sparky!uunet!cs.utexas.edu!torn!utgpu!utstat!rafal
  3. From: rafal@utstat.toronto.edu (Rafal Kustra (summer student))
  4. Subject: Re: gcc 2.3.3 problem
  5. Message-ID: <C1FtIy.M5F@utstat.toronto.edu>
  6. Organization: University of Toronto, Dept. of Statistics
  7. References: <1993Jan25.144702.4734@hp9000.csc.cuhk.hk>
  8. Date: Tue, 26 Jan 1993 01:30:34 GMT
  9. Lines: 47
  10.  
  11. In article <1993Jan25.144702.4734@hp9000.csc.cuhk.hk> a080700@hp9000.csc.cuhk.hk (Stephen Wong S M) writes:
  12. >I'm using linux 0.99pl4/SLS 1.0/gcc 2.3.3/lib 4.2 and I test the
  13. >gcc compiler with the following program:-
  14. >
  15. >test_sqrt.c
  16. >#include <math.h>
  17. >#include <stdio.h>
  18. >main()
  19. >{   double a;
  20. >    a = 2;
  21. >    printf("square root of 2 is %f\n", sqrt(a));
  22. >}
  23. >
  24. >I use the following command line to compile:-
  25. >gcc -lm -o test_sqrt test_sqrt.c
  26. >
  27. >but I got the following error message:-
  28. >/usr/tmp/cca001331.o: Undefined symbot _sqrt referenced from text segment
  29. >
  30. >Then I tried another command line:-
  31. >gcc -o test_sqrt test_sqrt.c /usr/lib/libm.a
  32. >
  33. >and succeed.
  34. >
  35. >My question is, is it a bug in gcc 2.3.3/lib 4.2 (libm.a), or something
  36. >I misunderstand?
  37. >
  38. >*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*
  39. >v Stephen Wong Siu-ming       v internet: stephenwong@cuhk.hk        v
  40. >^ Computer Services Center    ^ bitnet  : a080700@cucsc.bitnet       ^
  41. >* Chinese University of       * phone   : (852) 609-8904             *
  42. >v Hong Kong                   v fax     : (852) 603-5001             v
  43. >*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*
  44. >
  45.  
  46. I am sure this is RTFM stuff - man gcc. Libraries are
  47. linked as needed, so in the first case libm.a was not
  48. needed since it came before program -> not linked.
  49. Put -lm at the end - same as your second case.
  50.  
  51.             Rafal
  52.  
  53. -- 
  54. /|| " Numbers exist only in our minds. There is no physical entity that
  55.  ||  that _is_ number 1. If there were, 1 would be in a place of honor 
  56.  ||  in some great museum of science, and past it would file a 
  57. ==== steady stream of mathematicians gazing at 1 in wonder and awe. "
  58.