Pass -lm at end of linker command line The order of arguments to the gcc matters, and putting -lm at the beginning doesn't expose libm to subsequenly listedt object files.