本文记录在Windows下使用MinGW-w64编译安装PETSc的流程。
0、环境
操作系统 | Windows 11 |
MSYS2 | msys2-x86_64-20240507 |
1、开发环境
首先,下载并安装MSYS2,然后编辑PATH环境变量,添加mingw64相关路径:C:\msys64\mingw64\bin。
然后,下载并安装 msmpisetup.exe msmpisdk.msi 。
2、依赖
打开MSYS2 MINGW64控制台,备份/etc/pacman.d/mirrorlist.mingw64,
cp /etc/pacman.d/mirrorlist.mingw64 /etc/pacman.d/mirrorlist.mingw64.backup
然后编辑/etc/pacman.d/mirrorlist.mingw64以添加国内开源镜像源,并更新软件包数据库,
# Tsinghua
Server = https://mirrors.tuna.tsinghua.edu.cn/msys2/mingw/x86_64
pacman -Sy
运行以下命令安装依赖包,
pacman -S autoconf automake-wrapper bison bsdcpio make git \
mingw-w64-x86_64-toolchain patch python flex \
pkg-config pkgfile tar unzip mingw-w64-x86_64-cmake \
mingw-w64-x86_64-msmpi mingw-w64-x86_64-openblas mingw-w64-x86_64-jq
3. 下载PETSc源码
git clone -b release https://gitlab.com/petsc/petsc.git petsc
cd ./petsc/
git checkout v3.21.4
4、编译配置
export PETSC_ARCH=arch-mswin-c-debug-dmo
/usr/bin/python ./configure --prefix=/opt/petsc/arch-mswin-c-debug-dmo --with-debugging=1 --with-cc=mpicc --with-cxx=mpicxx --with-fc=mpif90 --with-openmp=1 --with-mpiexec='/C/Program\ Files/Microsoft\ MPI/Bin/mpiexec'
export PETSC_ARCH=arch-mswin-c-opt-dmo
/usr/bin/python ./configure --prefix=/opt/petsc/arch-mswin-c-opt-dmo --with-debugging=0 --with-cc=mpicc --with-cxx=mpicxx --with-fc=mpif90 --with-openmp=1 --with-mpiexec='/C/Program\ Files/Microsoft\ MPI/Bin/mpiexec'
5、编译与安装
make PETSC_DIR=/mingw64/src/petsc PETSC_ARCH=arch-mswin-c-debug-dmo all
make PETSC_DIR=/mingw64/src/petsc PETSC_ARCH=arch-mswin-c-debug-dmo install
make PETSC_DIR=/mingw64/src/petsc PETSC_ARCH=arch-mswin-c-opt-dmo all
make PETSC_DIR=/mingw64/src/petsc PETSC_ARCH=arch-mswin-c-opt-dmo install
网络资料
PETSchttps://petsc.org/release/
MSYS2https://www.msys2.org/
PETSCc安装与常见问题https://blog.csdn.net/qq_36130886/article/details/121731836