Results 1 to 2 of 2

Thread: math.h included, but fmod not available

  1. #1
    Join Date
    Jan 2006
    Location
    11 N 78 E
    Posts
    110
    Thanks
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Unhappy math.h included, but fmod not available

    I wrote a program to test my understanding of fmod:
    Qt Code:
    1. #include <stdio.h>
    2. #include <math.h>
    3.  
    4. int main(void) {
    5. double a = 259192.42201;
    6. double b = 24.10501259;
    7. printf("%11.10f", fmod(a,b));
    8. }
    To copy to clipboard, switch view to plain text mode 
    but I get the error:
    samjnaa@linux:~/bin/learning> gcc fmod.c -o fmod
    /tmp/ccK9XIYg.o: In function `main':
    fmod.c.text+0x49): undefined reference to `fmod'
    collect2: ld returned 1 exit status
    and sure enough /usr/include/math.h has no reference to fmod -- what is this, GCC libraries are useless? Then how do I implement a modulus function? My GCC version is 4.0.2_20050901-3 and I have cpp, libgcc of same version, glibc 2.3.5-40 etc. Please help. Thanks.
    Penguin #395953 using Qt for open-source development on X11 using C++ and
    Python via PyQt

  2. #2
    Join Date
    Jan 2006
    Location
    Shanghai, China
    Posts
    52
    Thanks
    3
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: math.h included, but fmod not available

    you need to link with the math library libm.a
    try gcc -o fmod -lm fmod.c
    1. Users don't have the manual, and if they did, they wouldn't read it.
    2. In fact, users can't read anything, and if they could, they wouldn't want to.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.