本文介绍了ld:对符号'log2 @@ GLIBC_2.2.5'的未定义引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

for (level = 1; level <= log2((double)size); level++)
                         ^

好像使用log2()一样,但是怎么了?我实际上将它与OpenMPI代码一起使用,但是注释此行可以解决问题.

Seems like its from using log2() but whats wrong? I am using it with OpenMPI code actually, but commenting this line fixes things.

完整源代码( http://pastie .org/7559178 ),请参见第40行

Full Source(http://pastie.org/7559178) see line 40

[jiewmeng@JM Assign3]$ mpicc -o cpi cpi.c && mpirun -np 16 cpi
/usr/bin/ld: /tmp/cca9x4he.o: undefined reference to symbol 'log2@@GLIBC_2.2.5'
/usr/bin/ld: note: 'log2@@GLIBC_2.2.5' is defined in DSO /usr/lib/libm.so.6 so try adding it to the linker command line
/usr/lib/libm.so.6: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status

似乎像log2(4)一样可以工作,但是我不能传递变量?

Seems like log2(4) will work but I cant pass in a variable?

推荐答案

为了链接libm,您需要添加-lm自变量,作为此文档; 数学部门在Linux下的MPI 说:

In in order to link libm you need to add -lm argument, as this document; MPI under Linux in the Math Department says:

mpicc -o sample sample.c -lm

mpicc -o sample sample.c -lm

这篇关于ld:对符号'log2 @@ GLIBC_2.2.5'的未定义引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-19 01:01