delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/10/14/10:55:40

Date: Wed, 14 Oct 1998 17:55:40 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: "Benjamin R. Saylor" <bsaylor AT arctic DOT net>
cc: djgpp AT delorie DOT com
Subject: Re: math - undefined references
In-Reply-To: <36243765.4497888F@arctic.net>
Message-ID: <Pine.SUN.3.91.981014175218.10409E-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com

On Tue, 13 Oct 1998, Benjamin R. Saylor wrote:

> When I compile my program, I get the message "undefined reference to
> sinf."  This doesn't happen with sin(), just sinf() (I haven't tried
> other *f()'s).  I've tried adding -lm to both the start and the end of
> the command line as it says in the FAQ, but it doesn't work!  What's
> going on?

The trivial one-liner below compiles fine (and runs) for me when I use 
the following compilation command line:

	gcc -Wall -D_USE_LIBM_MATH_H -O -g -o sft sft.c -lm

So please post more details, including the exact command line, the 
version of the compiler, etc.  Also try my program, just to be sure this 
isn't specific to your program.

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main (int argc, char **argv)
{
  return printf ("%f\n", sinf(atoi(argv[1])));
}

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019