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

gliese (2)
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"?
kbw (5371)
Each compiller defines its own set of default libraries. There's no portable way to get around specifying some common libraries.
Peter87 (3672)
-lm is only needed if you compile with gcc. g++ links the math library automatically.
SKZ81 (6)
You can use a Makefile !
Registered users can post here. Sign in or register to post.