From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8206 invoked by alias); 18 Dec 2011 14:17:28 -0000 Received: (qmail 8194 invoked by uid 22791); 18 Dec 2011 14:17:27 -0000 X-SWARE-Spam-Status: No, hits=-0.9 required=5.0 tests=AWL,BAYES_20,SPF_SOFTFAIL X-Spam-Check-By: sourceware.org Received: from smtp12.dentaku.gol.com (HELO smtp12.dentaku.gol.com) (203.216.5.74) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 18 Dec 2011 14:17:12 +0000 Received: from 61.245.22.93.eo.eaccess.ne.jp ([61.245.22.93] helo=catnip.gol.com) by smtp12.dentaku.gol.com with esmtpa (Dentaku) (envelope-from ) id 1RcHY6-0006S6-Ju; Sun, 18 Dec 2011 23:17:10 +0900 Received: by catnip.gol.com (Postfix, from userid 1000) id BFEA9DFB3; Sun, 18 Dec 2011 23:17:09 +0900 (JST) From: Miles Bader To: Xianwen Chen Cc: gcc-help@gcc.gnu.org Subject: Re: -lm and -lm64 problems References: System-Type: x86_64-unknown-linux-gnu Date: Sun, 18 Dec 2011 14:17:00 -0000 In-Reply-To: (Xianwen Chen's message of "Sun, 18 Dec 2011 06:30:39 -0700") Message-ID: <87r502dkwq.fsf@catnip.gol.com> MIME-Version: 1.0 Content-Type: text/plain X-Abuse-Complaints: abuse@gol.com Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2011-12/txt/msg00135.txt.bz2 Xianwen Chen writes: > 1) if I compile it as 'gcc -Wall -g -m64 -lm64 -o foo foo.c', it complains: > /usr/bin/ld: cannot find -lm64 > collect2: ld returned 1 exit status You should use "-lm" (not "-lm64"), regardless of -m64 or -m32 ... and: > 2) if I compile it as 'gcc -Wall -g -m64 -o foo foo.c', or 'gcc -Wall > -g -m32 -lm -o foo foo.c', it complains: > /dir/to/foo.c:15: undefined reference to `sqrt' > collect2: ld returned 1 exit status "-lm" should go _after_ anything that uses it. So: gcc -Wall -g -m64 -o foo foo.c -lm or: gcc -Wall -g -m32 -o foo foo.c -lm -Miles -- Year, n. A period of three hundred and sixty-five disappointments.