# FreeFEM compilation

**URL:** <https://community.freefem.org/t/freefem-compilation/4150>\
**Category:** FreeFEM installation\
**Created:** [December 10, 2025, 11:46pm UTC](https://community.freefem.org/t/freefem-compilation/4150 "2025-12-10T23:46:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aszaboa](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/aszaboa/32/2918_2.png) [@aszaboa](https://community.freefem.org/u/aszaboa)\
**Post date:** [December 10, 2025, 11:46pm UTC](https://community.freefem.org/t/freefem-compilation/4150/1 "2025-12-10T23:46:43Z")

</div>

Hello Everyone,

I am trying to compile the most recent version of FreeFEM from the develop branch. The compilation seems successful, but when I try to run the codes, I get random error messages, probably related to PETSc. E.g.,

```auto
[0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------
[0]PETSC ERROR: Argument out of range
[0]PETSC ERROR: Inserting a new nonzero at global row/column (6479, 8962) into matrix
[0]PETSC ERROR: WARNING! There are unused option(s) set! Could be the program crashed before usage or a spelling mistake, etc!
[0]PETSC ERROR: Option left: name:-nw value: navier-stokes-2d-PETSc.edp source: command line
[0]PETSC ERROR: Option left: name:-v value: 0 source: command line
[0]PETSC ERROR: See https://petsc.org/release/faq/ for trouble shooting.
[0]PETSC ERROR: PETSc Release Version 3.24.2, unknown
[0]PETSC ERROR: /home/andrasz/freefem/FreeFem-sources/src/mpi/FreeFem++-mpi with 4 MPI process(es) and PETSC_ARCH arch-FreeFem on cnre-ws-11 by andrasz Wed Dec 10 18:38:14 2025
[0]PETSC ERROR: Configure options: --download-cmake --download-mumps --download-parmetis --download-metis --download-hypre --download-superlu --download-slepc --download-hpddm --download-ptscotch --download-suitesparse --download-scalapack --with-fortran-bindings=no --with-scalar-type=real --with-debugging=no
[0]PETSC ERROR: #1 MatSetValues_MPIAIJ() at /home/andrasz/freefem/petsc/src/mat/impls/aij/mpi/mpiaij.c:612
[0]PETSC ERROR: #2 MatSetValues() at /home/andrasz/freefem/petsc/src/mat/interface/matrix.c:1601

```

I use the following commands to compile FreeFEM:

```auto
apt-get update && apt-get upgrade
sudo apt-get install cpp freeglut3-dev g++ gcc gfortran m4 make patch pkg-config wget unzip liblapack-dev libhdf5-dev libgsl-dev autoconf automake autotools-dev bison flex gdb git cmake
sudo apt-get install -y mpich
#================================ core installation 
export FF_DIR=${PWD}/FreeFem-sources
export PETSC_DIR=${PWD}/petsc 
export PETSC_ARCH=arch-FreeFem
export PETSC_VAR=${PETSC_DIR}/${PETSC_ARCH} 
git clone https://github.com/FreeFem/FreeFem-sources.git
git clone https://gitlab.com/petsc/petsc
cd ${PETSC_DIR} 
git checkout v3.24.2
./configure --download-cmake --download-mumps --download-parmetis --download-metis --download-hypre --download-superlu --download-slepc --download-hpddm --download-ptscotch --download-suitesparse --download-scalapack --with-fortran-bindings=no --with-scalar-type=real --with-debugging=no 
make -j10
export PETSC_ARCH=arch-FreeFem-complex 
./configure --with-cmake-dir=arch-FreeFem --with-mumps-dir=arch-FreeFem --with-parmetis-dir=arch-FreeFem --with-metis-dir=arch-FreeFem --with-superlu-dir=arch-FreeFem --download-slepc --download-hpddm --with-ptscotch-dir=arch-FreeFem --with-suitesparse-dir=arch-FreeFem --with-scalapack-dir=arch-FreeFem --with-fortran-bindings=no --with-scalar-type=complex --with-debugging=no 
make -j10 
cd ${FF_DIR} 
git checkout develop
autoreconf -i
./configure --without-hdf5 --enable-download_metis --enable-download_parmetis --enable-download_nlopt --enable-optim --with-petsc=${PETSC_VAR}/lib --with-petsc_complex=${PETSC_VAR}-complex/lib 
make -j10  

```

I attach the config.log of FreeFEM of PETSc. Any help would be much appreciated!

[config\_PETSc-complex.log](https://community.freefem.org/uploads/short-url/hIpXzTO8P7Y5XhMT0F16miVOS85.log) (1.3 MB)

[config\_PETSc.zip](https://community.freefem.org/uploads/short-url/rAXa88K5OeiDZVbA1KFVm9xUs8O.zip) (502.5 KB)

[config\_FreeFEM.log](https://community.freefem.org/uploads/short-url/q9D63iUCgSxy5x4JBRSSMjK7ifx.log) (163.5 KB)

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [December 11, 2025, 10:18am UTC](https://community.freefem.org/t/freefem-compilation/4150/2 "2025-12-11T10:18:44Z")

</div>

What if you let PETSc compile MPICH? Are you sure there is no other instances of `PETSc.so` (the FreeFEM plugin) somewhere else on the machine? Where does the error happen (inside FreeFEM sources or on a directory somewhere else)?

---

<div class="post-metadata">

**Author:** ![aszaboa](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/aszaboa/32/2918_2.png) [@aszaboa](https://community.freefem.org/u/aszaboa)\
**Post date:** [December 11, 2025, 5:14pm UTC](https://community.freefem.org/t/freefem-compilation/4150/3 "2025-12-11T17:14:37Z")

</div>

Thanks for the prompt reply. Compiling MPICH with PETSc seems to have resolved the issue.
