【发布时间】:2012-02-18 11:24:40
【问题描述】:
我一直在尝试构建一些使用数学函数的代码(例如pow)。
包含math.h,并且在构建期间使用标志-lm。
当像这样调用编译时(命令开头的-lm标志),它失败了,说有对pow的未定义引用:
gcc -lm -O3 main.o clustering.o grassberger.o hash.o list.o mat.o metropolis.o motif_ids.o output.o permutation.o prob.o random.o results.o role.o stubs.o switches.o -o mfinder
main.o: In function `get_sn_motif_id':
main.c:(.text+0x28d): undefined reference to `pow'
当-lm 标志放在命令末尾时,它就起作用了!
gcc -O3 main.o clustering.o grassberger.o hash.o list.o mat.o metropolis.o motif_ids.o output.o permutation.o prob.o random.o results.o role.o stubs.o switches.o -o mfinder -lm
这正常吗?
【问题讨论】:
-
糟糕。没有注意到这是一个老问题。