Article View: gnu.gcc.help
Article #41894Re: GCC won't Link with Math functions
From: Kevin Bailey
Date: Sun, 11 Feb 1996 00:00
Date: Sun, 11 Feb 1996 00:00
36 lines
1615 bytes
1615 bytes
In article <4etf9j$c75$1@mhafc.production.compuserve.com> Kelly Edwards <74127.3014@CompuServe.COM> writes: >From: Kelly Edwards <74127.3014@CompuServe.COM> >Subject: GCC won't Link with Math functions >Date: 2 Feb 1996 16:48:51 GMT >I am using gcc running under the Slackware version 2.2.0 of >Linux. I have been attempting to compile and link a c program >which includes several math functions such as cos, floor, pow, >etc. I keep getting undefined reference to cos (etc) messages. >Specifics include: >- I am compiling using gcc -g -lm -o output_name name.c >- I have included #include <math.h> >- I even tried using -I and -L options to include the directories >for math.h and libm.a >- program compiles OK with the -c option. >- This program compiles OK on an IBM RS6000. >Am I missing something obvious, or is the compiler not linking >the libm.a library as it should? I would appreciate any help >provided. >Thanks. >Kelly Edwards >Midland, TX >email 74127.3014@compuserve.com I found that -lm (which SHOULD link the math libraries) doesn't. Use this instead: gcc -o your_program your_program.o /usr/lib/libm.a Works for me!
Technical Details
Message-ID:
<speed.30.000D35DA@earthlink.net>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<4etf9j$c75$1@mhafc.production.compuserve.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,c8c72a5da0bb27a7 X-Google-Attributes: gid11318c,public From: speed@earthlink.net (Kevin Bailey) Subject: Re: GCC won't Link with Math functions Date: 1996/02/11 Message-ID: <speed.30.000D35DA@earthlink.net> X-Deja-AN: 139532345 references: <4etf9j$c75$1@mhafc.production.compuserve.com> organization: Earthlink Network, Inc. newsgroups: gnu.gcc.help