2013-04-15 13 views
12

? Ben aslında OpenMPI kodu ile kullanıyorum, ancak bu satırı yorumlamak şeyleri düzeltir. log2(4) çalışacak ama bir değişken geçmek olamaz gibild: sembole tanımsız referansı 'log2 @@ GLIBC_2.2.5'</p> <pre><code>for (level = 1; level <= log2((double)size); level++) ^ </code></pre> <p>onun dan <code>log2()</code> kullanarak ancak sorun ne gibi görünüyor birlikte Sorun ne

Full Source (http://pastie.org/7559178) bkz hattı 40

[[email protected] Assign3]$ mpicc -o cpi cpi.c && mpirun -np 16 cpi 
/usr/bin/ld: /tmp/cca9x4he.o: undefined reference to symbol '[email protected]@GLIBC_2.2.5' 
/usr/bin/ld: note: '[email protected]@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 

görünüyor?

cevap

27

libm'u bağlamak için, bu belge olarak -lm argümanını eklemeniz gerekir; MPI under Linux in the Math Department diyor ki: kodunuzu, (exp, cos, vs gibi) matematiksel işlevleri içerir

Eğer matematik kütüphanesi libm.so. bağlamanız gereken Bu benim ettik,

mpicc -o örnek sample.c, yani senin derleme komutunun sonuna lm ekleyerek, sadece seri derleme için olduğu gibi, lm

+0

Teşekkür yapılır bunu düzelt –

İlgili konular