home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.linux
- Path: sparky!uunet!cs.utexas.edu!torn!utgpu!utstat!rafal
- From: rafal@utstat.toronto.edu (Rafal Kustra (summer student))
- Subject: Re: gcc 2.3.3 problem
- Message-ID: <C1FtIy.M5F@utstat.toronto.edu>
- Organization: University of Toronto, Dept. of Statistics
- References: <1993Jan25.144702.4734@hp9000.csc.cuhk.hk>
- Date: Tue, 26 Jan 1993 01:30:34 GMT
- Lines: 47
-
- In article <1993Jan25.144702.4734@hp9000.csc.cuhk.hk> a080700@hp9000.csc.cuhk.hk (Stephen Wong S M) writes:
- >I'm using linux 0.99pl4/SLS 1.0/gcc 2.3.3/lib 4.2 and I test the
- >gcc compiler with the following program:-
- >
- >test_sqrt.c
- >#include <math.h>
- >#include <stdio.h>
- >main()
- >{ double a;
- > a = 2;
- > printf("square root of 2 is %f\n", sqrt(a));
- >}
- >
- >I use the following command line to compile:-
- >gcc -lm -o test_sqrt test_sqrt.c
- >
- >but I got the following error message:-
- >/usr/tmp/cca001331.o: Undefined symbot _sqrt referenced from text segment
- >
- >Then I tried another command line:-
- >gcc -o test_sqrt test_sqrt.c /usr/lib/libm.a
- >
- >and succeed.
- >
- >My question is, is it a bug in gcc 2.3.3/lib 4.2 (libm.a), or something
- >I misunderstand?
- >
- >*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*
- >v Stephen Wong Siu-ming v internet: stephenwong@cuhk.hk v
- >^ Computer Services Center ^ bitnet : a080700@cucsc.bitnet ^
- >* Chinese University of * phone : (852) 609-8904 *
- >v Hong Kong v fax : (852) 603-5001 v
- >*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*
- >
-
- I am sure this is RTFM stuff - man gcc. Libraries are
- linked as needed, so in the first case libm.a was not
- needed since it came before program -> not linked.
- Put -lm at the end - same as your second case.
-
- Rafal
-
- --
- /|| " Numbers exist only in our minds. There is no physical entity that
- || that _is_ number 1. If there were, 1 would be in a place of honor
- || in some great museum of science, and past it would file a
- ==== steady stream of mathematicians gazing at 1 in wonder and awe. "
-