I am using a program like this with math.h function "sin" and stdio.h function"printf" used
#include <stdio.h>
#include <math.h>
int main ()
{
int x = sin(14);
printf("hello");
return 0;
}
And as stated by ephemient here that libc.so and libm.so (for math functions) should have been linked with the program , though when I run otool (similar to objdump) on the object file with the option "-L" that prints the shared libraries used, None of libc.so or libm.so are printed out
otool -L com_ex1.o
so what is the reason for this ? Am I using otool wrong? or the those libraries shouldn't appear as shared libraries ?
Dynamic libraries are linked to the final executable, not to the object files, so you should run (e.g.)
This should show something like
because on OS X, the math library is part of libSystem: