Search code examples
cgccatan2

atan2() in gcc strange behavior, w_atan2.c: No such file or directory


I have included in my code the math.h and also used -lm but when i use the gcc debugger when it comes to atan2() i get the following:

16      result = atan2(x,y) * val;

(gdb) 

__atan2 (y=15, x=32) at w_atan2.c:31
31  w_atan2.c: No such file or directory.
(gdb) 

34  in w_atan2.c

(gdb) 

__ieee754_atan2_sse2 (y=15, x=32) at ../sysdeps/ieee754/dbl-64/e_atan2.c:92

my code is

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

#define PI 3.14159265


main(){

    double x, y, val, result;

    val = 180 / PI;
    x = 15;
    y = 32;

    result = atan2(x,y) * val;
    printf("%lf\n",result);

}

Solution

  • As best I can figure it out, by typing step into the debugger before the line result = atan2(x,y) * val; you're telling gdb to step into the atan2 function which will not work if you don't have the sources. You probably don't need to debug atan2 so next is probably the command you want.

    If you continue stepping after that you'll encounter a similar error when you hit printf, because you also can't step into that. If you really wanted to get into running the debugger on the library functions, there is some discussion here: http://ubuntuforums.org/showthread.php?t=1374829