Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

14
  • 2
    If you use your platform's tool to list the symbol table for an object file (e.g. nm ), are the missing functions listed in libm.a? The error indicates the problem is in the link phase, at which point the header files are no longer involved. In other words, the contents of math.h won't affect the issue. Commented Jun 30, 2011 at 11:49
  • 1
    Check your LD_LIBRARY_PATH. You might be looking at a different library to the one the linker is using. Remember that the header file math.h might also refer to a different library to the one being picked up. Commented Jun 30, 2011 at 13:09
  • 2
    Can you reproduce the problem with just one source file, building the executable without any makefiles, like so: gcc -o test test.c -lm or perhaps gcc -static -o test test.c -lm? Commented Jun 30, 2011 at 13:59
  • 1
    @hexa: That would change the behaviour of the compiler, not the content of the library. Dialect selection may remove parts of the header file, but that would cause a compiler not a linker error. Commented Jun 30, 2011 at 21:56
  • 3
    If you are compiling optimized the compiler can optimize away the run-time call to sin(1.0), replacing it by a constant computed at compile time. Have you #included <math.h> (see Jonathan's answer)? Commented Jul 1, 2011 at 16:08