having problems with math.h

From: damian birchler (damian_birchler_at_bluewin.ch)
Date: 09/12/04

  • Next message: Simon Barner: "Re: having problems with math.h"
    Date: 12 Sep 2004 10:24:59 -0700
    
    

    Im having problems trying to compile with gcc. When compiling I get a
    linker error which says "undefined reference to floor".

    My programme looks like this:

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

    int main(int argc, char *argv[]) {
            double mcp1(double n, double m);
            printf("%f\n", mcp1(3.0, 1000.0) + mcp1(5.0, 1000.0));
            return 0;
    }

    double mcp1(double n, double m) {
            double floor(double x);
            return (m * (floor(m/n) + 1.0)) / 2.0;
    }

    It's purpose is to sum all natural multiples of 3 and 5 up to 1000.

    Thanks in advance


  • Next message: Simon Barner: "Re: having problems with math.h"

    Relevant Pages

    • Re: GCC difference in size of long int on Suse SLES9 / Suse Professional 10.0
      ... The kernel uses printf() with 'long int', ... I can't compile 'on-the-fly'. ... clashing with the hardware and any libs that you interact with. ... platform types build up their own int types. ...
      (comp.os.linux.development.apps)
    • Re: Im a C++ programmer, and Relfs X.CPP is good.
      ... >> and it doesn't compile either. ... home.cpp:93: implicit declaration of function `int fclose' ... You cannot change to your home directory through an external ...
      (comp.lang.lisp)
    • Re: Im a C++ programmer, and Relfs X.CPP is good.
      ... >> and it doesn't compile either. ... home.cpp:93: implicit declaration of function `int fclose' ... You cannot change to your home directory through an external ...
      (comp.unix.programmer)
    • Re: new order doubt
      ... Warning test2.c: 8 no type specified. ... Defaulting to int ... Tests probably come in several different types: this should compile ... Even Microsoft has problems with this obscure rules. ...
      (comp.lang.c)
    • Re: non-static context
      ... public MyStatic(int length, int width) { ... Within the MyStatic constructor method, a local variable named area is ... This version of class MyStatic won't compile. ...
      (comp.lang.java.help)