Background: I originally learned C using Turbo C on DOS 6, in 1990; there were a lot of things that Turbo C treated as standard that apparently weren't (even then).
Now I'm refreshing myself by working through "88 C Programs". I've discovered that when I need to use functions from math.h
on GCC (like sqrt()
, log10()
, etc.), I have to manually link the math libraries by appending -lm
at the end of the GCC command. Is there a way to automate this action (say, with an environment variable), so that, if I have #include "math.h"
I automatically get -lm
added to the compile command and don't have to remember to type it?
As a single user on a quad-core CPU, I'm not terrifically concerned about tiny performance differences.
Potentially significant: I'm using the version of GCC and its dependencies found in the Ubuntu repositories, on Kubuntu 14.04.
Is there a way to set -lm as default for GCC?