公告
财富商城
积分规则
提问
发文
2019-02-06 02:12发布
老娘就宠你
What does -lm option do in g++ and when is it needed?
-lm
Is there a complete description of g++ options?
The option does nothing for g++: referring to this answer https://stackoverflow.com/a/1033940/1143274 libstdc++ requires libm, so it will always be linked by g++.
g++
libstdc++
libm
However, there is also some sort of an automatic linking behaviour for gcc, investigated on this thread http://www.linuxforums.org/forum/programming-scripting/125526-c-gcc-math-h-lm.html which I can't seem to find an answer as to where that comes from and which libraries it applies to...
gcc
That's a linker option. It tells the linker to link with (-l) the m library (libm.so/dll). That's the math library. You often need it if you #include <math.h>.
-l
m
#include <math.h>
最多设置5个标签!
The option does nothing for
g++
: referring to this answer https://stackoverflow.com/a/1033940/1143274libstdc++
requireslibm
, so it will always be linked byg++
.However, there is also some sort of an automatic linking behaviour for
gcc
, investigated on this thread http://www.linuxforums.org/forum/programming-scripting/125526-c-gcc-math-h-lm.html which I can't seem to find an answer as to where that comes from and which libraries it applies to...That's a linker option. It tells the linker to link with (
-l
) them
library (libm.so/dll). That's the math library. You often need it if you#include <math.h>
.