# Have problem about linking PETSC when install dolfinx using spack

**URL:** <https://fenicsproject.discourse.group/t/have-problem-about-linking-petsc-when-install-dolfinx-using-spack/16942>\
**Category:** dolfinx\
**Tags:** dolfinx\
**Created:** [February 6, 2025, 1:10pm UTC](https://fenicsproject.discourse.group/t/have-problem-about-linking-petsc-when-install-dolfinx-using-spack/16942 "2025-02-06T13:10:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![WjjSteve](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/wjjsteve/32/4389_2.png) [@WjjSteve](https://fenicsproject.discourse.group/u/WjjSteve)\
**Post date:** [February 6, 2025, 1:10pm UTC](https://fenicsproject.discourse.group/t/have-problem-about-linking-petsc-when-install-dolfinx-using-spack/16942/1 "2025-02-06T13:10:46Z")

</div>

Hello I tried to installed dolfinx on a HPC machine using spack, I followed this [guide](https://github.com/FEniCS/dolfinx/tree/main#:~:text=git%20clone%20https%3A//github.com/spack/spack.git%0A.%20./spack/share/spack/setup%2Denv.sh%0Aspack%20env%20create%20fenicsx%2Denv%0Aspack%20env%20activate%20fenicsx%2Denv%0Aspack%20add%20fenics%2Ddolfinx%2Badios2%20py%2Dfenics%2Ddolfinx%20cflags%3D%22%2DO3%22%20fflags%3D%22%2DO3%22%0Aspack%20install)

but changed the version to 0.7.2 since my code is written in this version. (I believe 0.7.2 is one of the safe version in spack.)  
So I replace the command to:

```auto
spack add fenics-dolfinx@0.7.2+adios2 py-fenics-dolfinx cflags="-O3" fflags="-O3"

```

But when I tried to compile my codes, I got the error message:

```auto
/proj/naiss2024-23-125/local/Work/spack/opt/spack/linux-centos7-broadwell/gcc-13.2.0/petsc-3.22.3-je3j3by35teir4hdfbsimwwa3l3kkls5/lib/libpetsc.so: undefined reference to `MPI_Neighbor_alltoallv_init'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/demo_poisson.dir/build.make:126: demo_poisson] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/demo_poisson.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

```

so it seems there is something wrong with the installation os PETSC. Does anyone has any suggestion or comment regarding my problem?  
Thanks a lot!

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [February 6, 2025, 3:39pm UTC](https://fenicsproject.discourse.group/t/have-problem-about-linking-petsc-when-install-dolfinx-using-spack/16942/2 "2025-02-06T15:39:12Z")

</div>

Seems like it is picking up a wrong/not modern enough mpi version. Could you check what you get with `mpirun —version` and `which mpirun`?

---

<div class="post-metadata">

**Author:** ![WjjSteve](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/wjjsteve/32/4389_2.png) [@WjjSteve](https://fenicsproject.discourse.group/u/WjjSteve)\
**Post date:** [February 6, 2025, 3:42pm UTC](https://fenicsproject.discourse.group/t/have-problem-about-linking-petsc-when-install-dolfinx-using-spack/16942/3 "2025-02-06T15:42:24Z")

</div>

Thanks for quick replying, here is the output:

```auto
-bash-4.2$ mpirun -version
mpirun (Open MPI) 5.0.6

Report bugs to https://www.open-mpi.org/community/help/

```

and

```auto
-bash-4.2$ which mpirun
/crex/proj/uppstore2017025/local/Work/spack/opt/spack/linux-centos7-broadwell/gcc-13.2.0/openmpi-5.0.6-6nysh7af27lxacxcz24rygtjhb752sb5/bin/mpirun

```

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [February 6, 2025, 4:13pm UTC](https://fenicsproject.discourse.group/t/have-problem-about-linking-petsc-when-install-dolfinx-using-spack/16942/4 "2025-02-06T16:13:58Z")

</div>

Hm, that is the latest version of mpich. Seems strange that it doesn’t find

> [@WjjSteve](#):
>
> ` `MPI\_Neighbor\_alltoallv\_init’`

It should be part of your openmpi installation

[https://docs.open-mpi.org/en/v5.0.6/man-openmpi/man3/MPI\_Neighbor\_alltoallv\_init.3.html](https://docs.open-mpi.org/en/v5.0.6/man-openmpi/man3/MPI_Neighbor_alltoallv_init.3.html)

Could you try pinning the PETSC version to an older version than 3.22?

---

<div class="post-metadata">

**Author:** ![WjjSteve](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/wjjsteve/32/4389_2.png) [@WjjSteve](https://fenicsproject.discourse.group/u/WjjSteve)\
**Post date:** [February 6, 2025, 9:06pm UTC](https://fenicsproject.discourse.group/t/have-problem-about-linking-petsc-when-install-dolfinx-using-spack/16942/5 "2025-02-06T21:06:51Z")

</div>

Hi I tried to install petsc@3.21.0 but still get the same problem, here is the packages I have installed:

```auto
-bash-4.2$ spack find petsc
==> In environment fenicsx-env
==> 3 root specs
[+] fenics-dolfinx@0.7.2 +adios2 [+] petsc@3.21.0 [+] py-fenics-dolfinx cflags=-O3 fflags=-O3 

-- linux-centos7-broadwell / gcc@13.2.0 -------------------------
petsc@3.21.0
==> 1 installed package
==> 0 concretized packages to be installed (show with `spack find -c`)

```

---

<div class="post-metadata">

**Author:** ![WjjSteve](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/wjjsteve/32/4389_2.png) [@WjjSteve](https://fenicsproject.discourse.group/u/WjjSteve)\
**Post date:** [February 7, 2025, 9:33am UTC](https://fenicsproject.discourse.group/t/have-problem-about-linking-petsc-when-install-dolfinx-using-spack/16942/6 "2025-02-07T09:33:47Z")

</div>

Oh, I just cleaned the old cache and configuration, now it works. Thanks!
