Article View: gnu.gcc.help
Article #41886Re: GCC won't Link with Math functions
From: Henry A. Irvine
Date: Sat, 10 Feb 1996 00:00
Date: Sat, 10 Feb 1996 00:00
28 lines
1574 bytes
1574 bytes
Mark P. Nelson wrote: > > Kelly Edwards (74127.3014@CompuServe.COM) wrote: > : 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 > > Try this instead: > > gcc -g -static name.c -o output_name -lm > > -- > Mark P. Nelson I was having a similar problem this evening, and the above solution works. In particular it is the -lm option to gcc which is the fix. This leads to the question, what other libraries must be explicitly specified and how can I figure out thier names? I am not terribly experienced with linux/gcc and have spent the last couple of days re-loading linux thinking that I had trashed some of the shared libraries somehow. -- Henry A. Irvine
Technical Details
Message-ID:
<311D3807.7BE016F9@interramp.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<4etf9j$c75$1@mhafc.production.compuserve.com> <4f5pli$p70@agate.berkeley.edu>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,c8c72a5da0bb27a7 X-Google-Attributes: gid11318c,public From: "Henry A. Irvine" <hirvine@interramp.com> Subject: Re: GCC won't Link with Math functions Date: 1996/02/10 Message-ID: <311D3807.7BE016F9@interramp.com> X-Deja-AN: 138823291 references: <4etf9j$c75$1@mhafc.production.compuserve.com> <4f5pli$p70@agate.berkeley.edu> content-type: text/plain; charset=us-ascii organization: PSI Public Usenet Link mime-version: 1.0 newsgroups: gnu.gcc.help x-mailer: Mozilla 2.0 (X11; I; Linux 1.3.54 i486)