Is there anyway in which I don't need to specify the linker when compiling?

For example, If my c++ code included math.h so that I can use sin().

When I compile my code, I need to add the linker, that is :

g++ main.cpp -lm

So my question is: Is there any way in which I don't need to add the "-lm"?
Each compiller defines its own set of default libraries. There's no portable way to get around specifying some common libraries.
-lm is only needed if you compile with gcc. g++ links the math library automatically.
You can use a Makefile !
Topic archived. No new replies allowed.