Extending Python with C: Cannot find MPI library

Spectrum spectrumdt at gmail.com
Thu Jun 19 17:09:20 CEST 2008


On Jun 19, 4:39 pm, Jeroen Ruigrok van der Werven <asmo... at in-
nomine.org> wrote:
> -On [20080619 16:21], Spectrum (spectru... at gmail.com) wrote:
>
> >          libmpi.so.0 => /usr/lib/openmpi/1.2.4-gcc/libmpi.so.0
> >(0x0042f000)
> >          libopen-rte.so.0 => /usr/lib/openmpi/1.2.4-gcc/libopen-
> >rte.so.0 (0x003d4000)
> >          libopen-pal.so.0 => /usr/lib/openmpi/1.2.4-gcc/libopen-
> >pal.so.0 (0x00344000)
>
> These libraries are what your binaries (.so and such) needs to link against
> as well. I am not sure if you have to add a flag (-mpi) to your compiler or
> if you need to add a -L/usr/lib/openmpi/1.2.4-gcc -lmpi -lopen-rte
> -lopen-pal to the incantations.

  Thanks for the reply.

  I did some more experimentation. The compiling commands I use are:

  mpicc -fno-strict-aliasing -DNDEBUG -O2 -g -pipe -Wall -Wp,-
D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-
size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -
D_GNU_SOURCE -fPIC -fPIC -I/usr/include/python2.5 -c ctest.c -o
ctest.o
  gcc -pthread -shared build/temp.linux-i686-2.5/ctest.o -L/usr/lib -
lpython2.5 -o ctest.so

  It turns out that changing the second "gcc" to "mpicc" causes the
module to no longer be includable. Python will give this error
message:

  ore at localhost Opgave03]$ python ctest.py
  Traceback (most recent call last):
    File "ctest.py", line 1, in <module>
      import ctest
  ImportError: dynamic module does not define init function
(initctest)
  [ore at localhost Opgave03]$

  The same happens if I try to add "-L/usr/lib/openmpi/1.2.4-gcc -lmpi
-lopen-rte -lopen-pal" as options to the second compilation command,
as you recommended.

  Looks like MPI doesn't like Python...



More information about the Python-list mailing list