Compilation of MPI C/C++ codes fails with mpich

Bug #1928981 reported by Christophe
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
mpich (Ubuntu)
Fix Committed
Undecided
Unassigned

Bug Description

 A few days ago, I have upgraded several machines from Ubuntu 20.10 to 21.04. Since then, I cannot compile anymore the C++ code that I am working on. The compilation (actually linking) with mpic++ fails with the following message

/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libmpich.a(lib_libmpich_la-ch3_init.o): undefined reference to symbol 'pthread_mutexattr_init@@GLIBC_2.2.5'
/usr/bin/ld : /lib/x86_64-linux-gnu/libpthread.so.0 : erreur lors de l'ajout de symboles : DSO missing from command line
collect2: error: ld returned 1 exit status

I tried to add -pthread -lpthread. I now get the message

/usr/bin/ld : /usr/lib/x86_64-linux-gnu/libmpich.a(ad_iwrite.o) : dans la fonction « ADIOI_GEN_aio_wait_fn » :
(.text+0x137) : référence indéfinie vers « aio_suspend »
/usr/bin/ld : (.text+0x191) : référence indéfinie vers « aio_error »
/usr/bin/ld : (.text+0x1a4) : référence indéfinie vers « aio_return »
/usr/bin/ld : /usr/lib/x86_64-linux-gnu/libmpich.a(ad_iwrite.o) : dans la fonction « ADIOI_GEN_aio_poll_fn » :
(.text+0x32a) : référence indéfinie vers « aio_error »
/usr/bin/ld : (.text+0x345) : référence indéfinie vers « aio_return »
/usr/bin/ld : /usr/lib/x86_64-linux-gnu/libmpich.a(ad_iwrite.o) : dans la fonction « ADIOI_GEN_aio » :
(.text+0x471) : référence indéfinie vers « aio_write »
/usr/bin/ld : (.text+0x501) : référence indéfinie vers « aio_read »
collect2: error: ld returned 1 exit status

Note that my code still compiles on other machines with older Ubuntu distribution.

The problem can be reproduced with the much simpler MPI example (taken from https://mpitutorial.com/tutorials/mpi-hello-world/)

#include <mpi.h>
#include <stdio.h>

int main(int argc, char** argv) {
    // Initialize the MPI environment
    MPI_Init(NULL, NULL);

    // Get the number of processes
    int world_size;
    MPI_Comm_size(MPI_COMM_WORLD, &world_size);

    // Get the rank of the process
    int world_rank;
    MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);

    // Get the name of the processor
    char processor_name[MPI_MAX_PROCESSOR_NAME];
    int name_len;
    MPI_Get_processor_name(processor_name, &name_len);

    // Print off a hello world message
    printf("Hello world from processor %s, rank %d out of %d processors\n",
           processor_name, world_rank, world_size);

    // Finalize the MPI environment.
    MPI_Finalize();
}

The compilation with the command mpicc test.c returns the error message

/usr/bin/ld : /usr/lib/x86_64-linux-gnu/libmpich.a(lib_libmpich_la-init_async.o) : dans la fonction « MPIR_Finalize_async_thread » :
(.text+0x4d2) : référence indéfinie vers « pthread_join »
/usr/bin/ld : /usr/lib/x86_64-linux-gnu/libmpich.a(lib_libmpich_la-ch3_init.o) : dans la fonction « split_type » :
(.text+0x159) : référence indéfinie vers « pthread_mutexattr_init »
/usr/bin/ld : (.text+0x166) : référence indéfinie vers « pthread_mutexattr_setpshared »
/usr/bin/ld : (.text+0x170) : référence indéfinie vers « pthread_mutexattr_destroy »
/usr/bin/ld : /usr/lib/x86_64-linux-gnu/libmpich.a(lib_libmpich_la-ch3_init.o) : dans la fonction « MPIDI_CH3I_Shm_supported » :
(.text+0x243) : référence indéfinie vers « pthread_mutexattr_init »
/usr/bin/ld : (.text+0x250) : référence indéfinie vers « pthread_mutexattr_setpshared »
/usr/bin/ld : (.text+0x25a) : référence indéfinie vers « pthread_mutexattr_destroy »
/usr/bin/ld : /usr/lib/x86_64-linux-gnu/libmpich.a(lib_libmpich_la-ch3_win_fns.o) : dans la fonction « MPIDI_CH3I_Win_allocate_shm » :
(.text+0x13a9) : référence indéfinie vers « pthread_mutexattr_init »
/usr/bin/ld : (.text+0x13ca) : référence indéfinie vers « pthread_mutexattr_setpshared »
/usr/bin/ld : (.text+0x1408) : référence indéfinie vers « pthread_mutexattr_destroy »
/usr/bin/ld : /usr/lib/x86_64-linux-gnu/libmpich.a(mpl_thread_posix.o) : dans la fonction « MPL_thread_create » :
(.text+0x70) : référence indéfinie vers « pthread_create »
/usr/bin/ld : /usr/lib/x86_64-linux-gnu/libmpich.a(ad_iwrite.o) : dans la fonction « ADIOI_GEN_aio_wait_fn » :
(.text+0x137) : référence indéfinie vers « aio_suspend »
/usr/bin/ld : (.text+0x191) : référence indéfinie vers « aio_error »
/usr/bin/ld : (.text+0x1a4) : référence indéfinie vers « aio_return »
/usr/bin/ld : /usr/lib/x86_64-linux-gnu/libmpich.a(ad_iwrite.o) : dans la fonction « ADIOI_GEN_aio_poll_fn » :
(.text+0x32a) : référence indéfinie vers « aio_error »
/usr/bin/ld : (.text+0x345) : référence indéfinie vers « aio_return »
/usr/bin/ld : /usr/lib/x86_64-linux-gnu/libmpich.a(ad_iwrite.o) : dans la fonction « ADIOI_GEN_aio » :
(.text+0x471) : référence indéfinie vers « aio_write »
/usr/bin/ld : (.text+0x501) : référence indéfinie vers « aio_read »

My system is up-to-date:
lsb_release -rd
Description: Ubuntu 21.04
Release: 21.04

dpkg -l "*mpich*"
Souhait=inconnU/Installé/suppRimé/Purgé/H=à garder
| État=Non/Installé/fichier-Config/dépaqUeté/échec-conFig/H=semi-installé/W=attend-traitement-déclenchements
|/ Err?=(aucune)/besoin Réinstallation (État,Err: majuscule=mauvais)
||/ Nom Version Architecture Description
+++-==================-=============-============-============================================================
ii libmpich-dev:amd64 3.4.1-3build1 amd64 Development files for MPICH
ii libmpich12:amd64 3.4.1-3build1 amd64 Shared libraries for MPICH
ii mpich 3.4.1-3build1 amd64 Implementation of the MPI Message Passing Interface standard

apt-cache policy mpich
mpich:
  Installé : 3.4.1-3build1
  Candidat : 3.4.1-3build1
 Table de version :
 *** 3.4.1-3build1 500
        500 http://fr.archive.ubuntu.com/ubuntu hirsute/universe amd64 Packages
        100 /var/lib/dpkg/status

ProblemType: Bug
DistroRelease: Ubuntu 21.04
Package: mpich 3.4.1-3build1
ProcVersionSignature: Ubuntu 5.11.0-17.18-generic 5.11.12
Uname: Linux 5.11.0-17-generic x86_64
ApportVersion: 2.20.11-0ubuntu65
Architecture: amd64
CasperMD5CheckResult: unknown
CurrentDesktop: LXQt
Date: Wed May 19 20:51:59 2021
InstallationDate: Installed on 2019-01-20 (849 days ago)
InstallationMedia: Ubuntu 18.04.1 LTS "Bionic Beaver" - Release amd64 (20180725)
SourcePackage: mpich
UpgradeStatus: Upgraded to hirsute on 2021-05-13 (6 days ago)

Revision history for this message
Christophe (chatelai) wrote :
Revision history for this message
Christophe (chatelai) wrote :

Solution: reinstall mpich !

Christophe (chatelai)
Changed in mpich (Ubuntu):
status: New → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.