Build PETSc in windows under mingw64

Installation of PETSc on windows is suggested in the official site of PETSc under cygwin and by specific script 'win32fe' provided. It could be, however, compiled in native windows under mingw64 with a few points should follows,

1. Don't use Windows style git such as TortoiseGit. Use git of msys2.

2. Specify your MPI environment by --with-mpi-include=<your mpi include folder> and --with-mpi-lib=<your mpi library>

3. Don't use ar in /mingw64/bin/ar by specify --with-ar=/usr/bin/ar

4. Set the gfortran compiler option by 'FOPTFLAGS=-fno-range-check'

The python script would something like:

#!/usr/bin/env python2

configure_options = [
  '--with-mpi-include=/mingw64/include',
  '--with-mpi-lib=/mingw64/lib/libmsmpi.a',
  '--with-ar=/usr/bin/ar' ,
  '--with-shared-libraries=0',
  '--with-debugging=0',
  '--with-visibility=0',
  '--prefix=/usr/local/petsc',
  'FOPTFLAGS=-O3 -fno-range-check',
  ]

if __name__ == '__main__':
  import sys,os
  sys.path.insert(0,os.path.abspath('config'))
  import configure
  configure.petsc_configure(configure_options)

5. Don't use python in /usr/bin/python other than /mingw/bin/python
   e.g. runing the above script by type in > /usr/bin/python <your python script name>

Compilation of PETSc3.8.2 tests successfully!

1 条评论:

  1. Hello, can you send me a static library package of PETSC compiled by you? If so, thank you very much

    回复删除

VS Code下cmake, c++编译,调试环境的构成步骤

1   下载必须extension      按[Ctrl+Shift+X]打开extension窗口,选择安装"C/C++", "CMake", "CMake Tools" 2   在VSCode下打开作业目录 ...