Extending Python with C: Cannot find MPI library

Spectrum spectrumdt at gmail.com
Thu Jun 19 10:16:57 EDT 2008


On Jun 19, 2:10 pm, Jeroen Ruigrok van der Werven <asmo... at in-
nomine.org> wrote:
> -On [20080619 13:53], Spectrum (spectru... at gmail.com) wrote:
>
> >  ImportError: /big/School/Cluster/Opgave03/ctest.so: undefined
> >symbol: ompi_mpi_comm_world
> >  [ore at localhost Opgave03]$
>
> >  Can anyone suggest anything? Can I get MPI to work in Python?
>
> Sounds like a typical case of not specifying any -L and/or -l options. In
> this case the ctest.so module has an undefined reference to the symbol
> ompi_mpi_comm_world and cannot resolve it. So either it was not linked
> properly or the loader cannot find the required library.
>
> Apply nm -D and ldd to the .so and see what ails.

  Thanks for the reply.

  It is very likely that I am not compiling properly. I am a sucky C
programmer.

  The commands you recommended give the following output:

  [ore at localhost Opgave03]$ nm -D ctest.so
          U MPI_Comm_rank
          U MPI_Finalize
          U MPI_Init
          w _Jv_RegisterClasses
  000018cc A __bss_start
          w __cxa_finalize
          w __gmon_start__
          U __printf_chk
  000018cc A _edata
  000018d4 A _end
  000006c4 T _fini
  00000414 T _init
  00000600 T hello
  00000650 T main
          U ompi_mpi_comm_world
  000005b0 T rank
  [ore at localhost Opgave03]$
  [ore at localhost Opgave03]$
  [ore at localhost Opgave03]$ ldd ctest.so
          linux-gate.so.1 =>  (0x00110000)
          libpython2.5.so.1.0 => /usr/lib/libpython2.5.so.1.0
(0x00113000)
          libpthread.so.0 => /lib/libpthread.so.0 (0x0025a000)
          libc.so.6 => /lib/libc.so.6 (0x00342000)
          libdl.so.2 => /lib/libdl.so.2 (0x00273000)
          libutil.so.1 => /lib/libutil.so.1 (0x00278000)
          libm.so.6 => /lib/libm.so.6 (0x0027c000)
          /lib/ld-linux.so.2 (0x00325000)
  [ore at localhost Opgave03]$



  The same commands, when applied to the mpicc-compiled, correctly-
functioning C program (in this case just named 'a.out') give this:



  [ore at localhost Opgave03]$ ./a.out
  Hello, World. I am process 0.
  [ore at localhost Opgave03]$ nm -D a.out
          U MPI_Comm_rank
          U MPI_Finalize
          U MPI_Init
  08048818 R _IO_stdin_used
          w _Jv_RegisterClasses
  080499fc A __bss_start
  080499f8 D __data_start
          w __gmon_start__
  08048750 T __libc_csu_fini
  08048760 T __libc_csu_init
          U __libc_start_main
  080499fc A _edata
  08049b10 A _end
  080487f8 T _fini
  08048814 R _fp_hw
  08048560 T _init
  080485f0 T _start
  080499f8 W data_start
  080486f9 T hello
  0804871f T main
  08049a00 B ompi_mpi_comm_world
          U printf
  080486c4 T rank
  [ore at localhost Opgave03]$ ldd a.out
          linux-gate.so.1 =>  (0x00110000)
          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)
          libdl.so.2 => /lib/libdl.so.2 (0x00df0000)
          libnsl.so.1 => /lib/libnsl.so.1 (0x003b9000)
          libutil.so.1 => /lib/libutil.so.1 (0x004d8000)
          libm.so.6 => /lib/libm.so.6 (0x0025c000)
          libpthread.so.0 => /lib/libpthread.so.0 (0x00287000)
          libc.so.6 => /lib/libc.so.6 (0x004dc000)
          /lib/ld-linux.so.2 (0x00325000)
  [ore at localhost Opgave03]$



  I don't know how to interpret these, so can I get some more advice?

  Thanks in advance.

  - Claus Appel




More information about the Python-list mailing list