【发布时间】:2017-03-04 22:18:30
【问题描述】:
我在我的 C 源代码中包含了 <math.h> 库。但是我得到了编译错误。
Error:
**undefined reference to 'sqrt'
**undefined reference to 'atan'
如何在CMakeLists.txt 中链接到<math.h>?
【问题讨论】:
-
只是出于好奇——如果编译器是 gcc 并且目标系统是 Solaris,我可能需要使用编译器选项
-lm来静态链接数学库。如果使用 gcc,其他目标系统也可能如此。 -
是的,我知道。但我必须在编辑器上构建它。为此,我必须在 cmakelists.txt 中添加“math.h”