This guide explains how to build PETSc using Visual Studio 2026 (x64) and Intel oneAPI (MPI + MKL) in a Cygwin environment.
-
Visual Studio 2026 (Community, Professional, or Enterprise)
- Install C++ development tools
-
Intel oneAPI (Base Toolkit + HPC Toolkit)
- Base Toolkit: Includes MKL (Math Kernel Library)
- HPC Toolkit: Includes Intel MPI
-
Cygwin (64-bit)
- Required packages:
python3,make,git
- Required packages:
The configuration uses 64-bit libraries:
- Intel MKL with
lp64(64-bit long pointers) - Intel MPI (64-bit)
Using the wrong architecture will cause linker errors.
Open Cygwin Terminal and set up the Visual Studio x64 environment:
# Method 1: Use VS Developer Command Prompt first, then launch Cygwin
# Open: "x64 Native Tools Command Prompt for VS 2026"
# Then run: C:\cygwin64\bin\bash.exe --login
# Method 2: Set environment variables manually in Cygwin
export VSINSTALLDIR="/cygdrive/c/Program Files/Microsoft Visual Studio/2026/Community"
export VCVARSALL="$VSINSTALLDIR/VC/Auxiliary/Build/vcvarsall.bat"
# Load VS environment (x64 architecture)
cmd.exe /c "\"$VCVARSALL\" x64 && set" | sed 's/\\/\//g; s/C:/\/cygdrive\/c/g' > /tmp/vsenv.sh
source /tmp/vsenv.shCheck that you're using the 64-bit compiler:
cl.exe 2>&1 | grep -i "optimizing compiler"Expected output should include "for x64":
Microsoft (R) C/C++ Optimizing Compiler Version 19.50.xxxxx for x64
❌ If you see "for x86", you're using the wrong compiler!
Verify your Intel oneAPI installation paths:
# Intel oneAPI root (adjust if different)
INTEL_ONEAPI="/cygdrive/c/OPT/Intel/oneAPI"
# Check MKL libraries exist
ls "$INTEL_ONEAPI/mkl/2025.3/lib/"
# Check MPI libraries exist
ls "$INTEL_ONEAPI/mpi/2021.17/lib/"
ls "$INTEL_ONEAPI/mpi/2021.17/include/"export PETSC_DIR=/cygdrive/d/temp/petsc-3.24.3
cd $PETSC_DIRUse the provided configuration script:
python3 config/examples/win-vs2026.pyConfigure output:
=============================================================================================
Configuring PETSc to compile on your system
=============================================================================================
=============================================================================================
***** WARNING *****
Using default C optimization flags "-O2 -QxW". You might consider manually setting
optimal optimization flags for your system with COPTFLAGS="optimization flags" see
config/examples/arch-*-opt.py for examples
=============================================================================================
=============================================================================================
***** WARNING *****
Using default Cxx optimization flags "-O2 -QxW -Zm200". You might consider manually
setting optimal optimization flags for your system with CXXOPTFLAGS="optimization flags"
see config/examples/arch-*-opt.py for examples
=============================================================================================
Compilers:
C Compiler: /cygdrive/d/temp/petsc-3.24.3/lib/petsc/bin/win32fe/win32fe_cl -GF -MD -wd4996 -Zc:preprocessor -O2
Version: Win32 Development Tool Front End, version 1.11.4 Fri, Sep 10, 2021 6:33:40 PM\nMicrosoft (R) C/C++ Optimizing Compiler Version 19.50.35723 for x64
C++ Compiler: /cygdrive/d/temp/petsc-3.24.3/lib/petsc/bin/win32fe/win32fe_cl -GF -MD -GR -EHsc -Zc:preprocessor -Zc:__cplusplus -O2 -Zm200 -std:c++20 -TP
Version: Win32 Development Tool Front End, version 1.11.4 Fri, Sep 10, 2021 6:33:40 PM\nMicrosoft (R) C/C++ Optimizing Compiler Version 19.50.35723 for x64
Linkers:
Shared linker: /cygdrive/d/temp/petsc-3.24.3/lib/petsc/bin/win32fe/win32fe_cl -LD -GF -MD -wd4996 -Zc:preprocessor -O2
Python:
Executable: /usr/bin/python
BlasLapack:
Libraries: -L/cygdrive/c/OPT/Intel/oneAPI/mkl/2025.3/lib mkl_intel_lp64_dll.lib mkl_sequential_dll.lib mkl_core_dll.lib
Unknown if this uses OpenMP (try export OMP_NUM_THREADS=<1-4> yourprogram -log_view)
uses 8 byte integers
MPI:
Version: 4
Includes: -I/cygdrive/c/OPT/Intel/oneAPI/mpi/2021.17/include
Libraries: /cygdrive/c/OPT/Intel/oneAPI/mpi/2021.17/lib/impi.lib
mpiexec: /cygdrive/c/OPT/Intel/oneAPI/mpi/2021.17/bin/mpiexec.exe -localonly
Implementation: mpich2
MPICH_NUMVERSION: 30400002 I_MPI_NUMVERSION: 20211700300
CMake:
Version: 3.23.2
Executable: /usr/bin/cmake
PETSc:
Language used to compile PETSc: C
PETSC_ARCH: win-vs2026
PETSC_DIR: /cygdrive/d/temp/petsc-3.24.3
Prefix: win-vs2026
Scalar type: real
Precision: double
Integer size: 4 bytes
Single library: yes
Shared libraries: yes
Memory alignment from malloc(): 16 bytes
Using GNU make: /usr/bin/make
xxx=======================================================================================xxx
Configure stage complete. Now build PETSc libraries with:
make PETSC_DIR=/cygdrive/d/temp/petsc-3.24.3 PETSC_ARCH=win-vs2026 all
xxx=======================================================================================xxx
After successful configuration:
make PETSC_DIR=/cygdrive/d/temp/petsc-3.24.3 PETSC_ARCH=win-vs2026 allOutput snippet:
/usr/bin/python ./config/gmakegen.py --petsc-arch=win-vs2026
make[2]: Entering directory '/cygdrive/d/temp/petsc-3.24.3'
==========================================
See documentation/faq.html and documentation/bugreporting.html
for help with installation problems. Please send EVERYTHING
printed out below when reporting problems. Please check the
mailing list archives and consider subscribing.
https://petsc.org/release/community/mailing/
==========================================
Starting make run on ASUS at Mon, 26 Jan 2026 00:51:08 -0600
Machine characteristics: CYGWIN_NT-10.0-26200 ASUS 3.5.3-1.x86_64 2024-04-03 17:25 UTC x86_64 Cygwin
-----------------------------------------
Using PETSc directory: /cygdrive/d/temp/petsc-3.24.3
Using PETSc arch: win-vs2026
-----------------------------------------
PETSC_VERSION_RELEASE 1
PETSC_VERSION_MAJOR 3
PETSC_VERSION_MINOR 24
PETSC_VERSION_SUBMINOR 3
PETSC_VERSION_DATE "Jan 01, 2026"
PETSC_VERSION_GIT "v3.24.3"
PETSC_VERSION_DATE_GIT "2026-01-01 17:01:02 -0600"
-----------------------------------------
Using configure Options: --package-prefix-hash=/home/shubi/petsc-hash-pkgs --with-debugging=0 --with-blaslapack-lib="-L/cygdrive/c/OPT/Intel/oneAPI/mkl/2025.3/lib mkl_intel_lp64_dll.lib mkl_sequential_dll.lib mkl_core_dll.lib" --with-cc=/cygdrive/d/temp/petsc-3.24.3/lib/petsc/bin/win32fe/win32fe_cl --with-cxx=/cygdrive/d/temp/petsc-3.24.3/lib/petsc/bin/win32fe/win32fe_cl --with-fc=0 --with-mpi=1 --with-mpi-include=/cygdrive/c/OPT/Intel/oneAPI/mpi/2021.17/include --with-mpi-lib=/cygdrive/c/OPT/Intel/oneAPI/mpi/2021.17/lib/impi.lib --with-mpiexec="/cygdrive/c/OPT/Intel/oneAPI/mpi/2021.17/bin/mpiexec.exe -localonly" --with-64-bit-indices=0 --with-single-library=1 --with-endian=little --with-debugging=0 --with-x=0 --with-windows-graphics=0 PETSC_ARCH=win-vs2026
Using configuration flags:
#define PETSC_ARCH ""
#define PETSC_ATTRIBUTEALIGNED(size)
#define PETSC_CANNOT_START_DEBUGGER 1
#define PETSC_CLANGUAGE_C 1
#define PETSC_CXX_RESTRICT __restrict
#define PETSC_DEPRECATED_ENUM_BASE(string_literal_why)
#define PETSC_DEPRECATED_FUNCTION_BASE(string_literal_why) __declspec(deprecated(string_literal_why))
#define PETSC_DEPRECATED_MACRO_BASE(string_literal_why) PETSC_DEPRECATED_MACRO_BASE_(GCC warning string_literal_why)
#define PETSC_DEPRECATED_MACRO_BASE_(why) _Pragma(#why)
#define PETSC_DEPRECATED_OBJECT_BASE(string_literal_why) __declspec(deprecated(string_literal_why))
#define PETSC_DEPRECATED_TYPEDEF_BASE(string_literal_why)
#define PETSC_DIR "D:\\temp\\petsc-3.24.3"
#define PETSC_DIR_SEPARATOR '\\'
#define PETSC_FUNCTION_NAME_C __func__
#define PETSC_FUNCTION_NAME_CXX __func__
#define PETSC_HAVE_64BIT_BLAS_INDICES 1
#define PETSC_HAVE_ACCESS 1
#define PETSC_HAVE_ATOLL 1
#define PETSC_HAVE_CLOCK 1
#define PETSC_HAVE_CLOSESOCKET 1
#define PETSC_HAVE_CXX 1
#define PETSC_HAVE_CXX_COMPLEX 1
#define PETSC_HAVE_CXX_COMPLEX_FIX 1
#define PETSC_HAVE_CXX_DIALECT_CXX11 1
#define PETSC_HAVE_CXX_DIALECT_CXX14 1
#define PETSC_HAVE_CXX_DIALECT_CXX17 1
#define PETSC_HAVE_CXX_DIALECT_CXX20 1
#define PETSC_HAVE_DIRECT_H 1
#define PETSC_HAVE_DOS_H 1
#define PETSC_HAVE_DOUBLE_ALIGN_MALLOC 1
#define PETSC_HAVE_ERF 1
#define PETSC_HAVE_FCNTL_H 1
#define PETSC_HAVE_FENV_H 1
#define PETSC_HAVE_FE_VALUES 1
#define PETSC_HAVE_FLOAT_H 1
#define PETSC_HAVE_FREELIBRARY 1
#define PETSC_HAVE_GETCOMPUTERNAME 1
#define PETSC_HAVE_GETCWD 1
#define PETSC_HAVE_GETLASTERROR 1
#define PETSC_HAVE_GETPROCADDRESS 1
#define PETSC_HAVE_GET_USER_NAME 1
#define PETSC_HAVE_IMMINTRIN_H 1
#define PETSC_HAVE_INTTYPES_H 1
#define PETSC_HAVE_IO_H 1
#define PETSC_HAVE_ISINF 1
#define PETSC_HAVE_ISNAN 1
#define PETSC_HAVE_ISNORMAL 1
#define PETSC_HAVE_I_MPI 1
#define PETSC_HAVE_LARGE_INTEGER_U 1
#define PETSC_HAVE_LGAMMA 1
#define PETSC_HAVE_LOADLIBRARY 1
#define PETSC_HAVE_LOG2 1
#define PETSC_HAVE_LSEEK 1
#define PETSC_HAVE_MALLOC_H 1
#define PETSC_HAVE_MEMMOVE 1
#define PETSC_HAVE_MKL_INTEL_ILP64 1
#define PETSC_HAVE_MKL_LIBS 1
#define PETSC_HAVE_MPICH 1
#define PETSC_HAVE_MPIIO 1
#define PETSC_HAVE_MPI_COMBINER_CONTIGUOUS 1
#define PETSC_HAVE_MPI_COMBINER_DUP 1
#define PETSC_HAVE_MPI_COMBINER_NAMED 1
#define PETSC_HAVE_MPI_COUNT 1
#define PETSC_HAVE_MPI_F90MODULE_VISIBILITY 1
#define PETSC_HAVE_MPI_GET_ACCUMULATE 1
#define PETSC_HAVE_MPI_GET_LIBRARY_VERSION 1
#define PETSC_HAVE_MPI_INIT_THREAD 1
#define PETSC_HAVE_MPI_INT64_T 1
#define PETSC_HAVE_MPI_LARGE_COUNT 1
#define PETSC_HAVE_MPI_LONG_DOUBLE 1
#define PETSC_HAVE_MPI_NEIGHBORHOOD_COLLECTIVES 1
#define PETSC_HAVE_MPI_NONBLOCKING_COLLECTIVES 1
#define PETSC_HAVE_MPI_ONE_SIDED 1
#define PETSC_HAVE_MPI_PERSISTENT_NEIGHBORHOOD_COLLECTIVES 1
#define PETSC_HAVE_MPI_PROCESS_SHARED_MEMORY 1
#define PETSC_HAVE_MPI_REDUCE_LOCAL 1
#define PETSC_HAVE_MPI_REDUCE_SCATTER_BLOCK 1
#define PETSC_HAVE_MPI_RGET 1
#define PETSC_HAVE_MPI_WIN_CREATE 1
#define PETSC_HAVE_O_BINARY 1
#define PETSC_HAVE_PACKAGES ":blaslapack:mathlib:mpi:"
#define PETSC_HAVE_RAND 1
#define PETSC_HAVE_SETJMP_H 1
#define PETSC_HAVE_SETLASTERROR 1
#define PETSC_HAVE_STDINT_H 1
#define PETSC_HAVE_STRICMP 1
#define PETSC_HAVE_SYS_TYPES_H 1
#define PETSC_HAVE_TAU_PERFSTUBS 1
#define PETSC_HAVE_TGAMMA 1
#define PETSC_HAVE_TIME 1
#define PETSC_HAVE_TIME_H 1
#define PETSC_HAVE_TMPNAM_S 1
#define PETSC_HAVE_VA_COPY 1
#define PETSC_HAVE_VSNPRINTF 1
#define PETSC_HAVE_WINDOWSX_H 1
#define PETSC_HAVE_WINDOWS_COMPILERS 1
#define PETSC_HAVE_WINDOWS_H 1
#define PETSC_HAVE_WINSOCK2_H 1
#define PETSC_HAVE_WS2TCPIP_H 1
#define PETSC_HAVE_WSAGETLASTERROR 1
#define PETSC_HAVE_XMMINTRIN_H 1
#define PETSC_HAVE__ACCESS 1
#define PETSC_HAVE__GETCWD 1
#define PETSC_HAVE__LSEEK 1
#define PETSC_HAVE__MKDIR 1
#define PETSC_HAVE__SLEEP 1
#define PETSC_HAVE___INT64 1
#define PETSC_INTPTR_T intptr_t
#define PETSC_INTPTR_T_FMT "#" PRIxPTR
#define PETSC_IS_COLORING_MAX USHRT_MAX
#define PETSC_IS_COLORING_VALUE_TYPE short
#define PETSC_IS_COLORING_VALUE_TYPE_F integer2
#define PETSC_LEVEL1_DCACHE_LINESIZE 32
#define PETSC_LIB_DIR "/cygdrive/d/temp/petsc-3.24.3/win-vs2026/lib"
#define PETSC_LIB_NAME_SUFFIX ""
#define PETSC_MAX_PATH_LEN 4096
#define PETSC_MEMALIGN 16
#define PETSC_MISSING_GETLINE 1
#define PETSC_MISSING_SIGALRM 1
#define PETSC_MISSING_SIGBUS 1
#define PETSC_MISSING_SIGCHLD 1
#define PETSC_MISSING_SIGCONT 1
#define PETSC_MISSING_SIGHUP 1
#define PETSC_MISSING_SIGKILL 1
#define PETSC_MISSING_SIGPIPE 1
#define PETSC_MISSING_SIGQUIT 1
#define PETSC_MISSING_SIGSTOP 1
#define PETSC_MISSING_SIGSYS 1
#define PETSC_MISSING_SIGTRAP 1
#define PETSC_MISSING_SIGTSTP 1
#define PETSC_MISSING_SIGURG 1
#define PETSC_MISSING_SIGUSR1 1
#define PETSC_MISSING_SIGUSR2 1
#define PETSC_MPICC_SHOW "Unavailable"
#define PETSC_MPIU_IS_COLORING_VALUE_TYPE MPI_UNSIGNED_SHORT
#define PETSC_NEEDS_UTYPE_TYPEDEFS 1
#define PETSC_OMAKE "/usr/bin/make --no-print-directory"
#define PETSC_PKG_I_MPI_NUMVERSION 20211700300
#define PETSC_PKG_MPICH_NUMVERSION 30400002
#define PETSC_PREFETCH_HINT_NTA _MM_HINT_NTA
#define PETSC_PREFETCH_HINT_T0 _MM_HINT_T0
#define PETSC_PREFETCH_HINT_T1 _MM_HINT_T1
#define PETSC_PREFETCH_HINT_T2 _MM_HINT_T2
#define PETSC_PYTHON_EXE "/usr/bin/python"
#define PETSC_Prefetch(a,b,c) _mm_prefetch((const char*)(a),(c))
#define PETSC_REPLACE_DIR_SEPARATOR '/'
#define PETSC_SIGNAL_CAST
#define PETSC_SIZEOF_INT 4
#define PETSC_SIZEOF_LONG 4
#define PETSC_SIZEOF_LONG_LONG 8
#define PETSC_SIZEOF_SIZE_T 8
#define PETSC_SIZEOF_VOID_P 8
#define PETSC_SLSUFFIX "dll"
#define PETSC_UINTPTR_T uintptr_t
#define PETSC_UINTPTR_T_FMT "#" PRIxPTR
#define PETSC_UNUSED
#define PETSC_USE_AVX512_KERNELS 1
#define PETSC_USE_CTABLE 1
#define PETSC_USE_DMLANDAU_2D 1
#define PETSC_USE_INFO 1
#define PETSC_USE_ISATTY 1
#define PETSC_USE_LOG 1
#define PETSC_USE_MALLOC_COALESCED 1
#define PETSC_USE_MICROSOFT_TIME 1
#define PETSC_USE_PROC_FOR_SIZE 1
#define PETSC_USE_REAL_DOUBLE 1
#define PETSC_USE_SHARED_LIBRARIES 1
#define PETSC_USE_SINGLE_LIBRARY 1
#define PETSC_USING_64BIT_PTR 1
#define PETSC__BSD_SOURCE 1
#define PETSC__DEFAULT_SOURCE 1
#define R_OK 04
#define S_ISDIR(a) (((a)&_S_IFMT) == _S_IFDIR)
#define S_ISREG(a) (((a)&_S_IFMT) == _S_IFREG)
#define W_OK 02
#define X_OK 01
#define _USE_MATH_DEFINES 1
-----------------------------------------
Using C compile: /cygdrive/d/temp/petsc-3.24.3/lib/petsc/bin/win32fe/win32fe_cl -o gmakeinfo -c -GF -MD -wd4996 -Zc:preprocessor -O2
mpicc -show: Unavailable
C compiler version: Win32 Development Tool Front End, version 1.11.4 Fri, Sep 10, 2021 6:33:40 PM
Microsoft (R) C/C++ Optimizing Compiler Version 19.50.35723 for x64
Using C++ compile: /cygdrive/d/temp/petsc-3.24.3/lib/petsc/bin/win32fe/win32fe_cl -o gmakeinfo -c -GF -MD -GR -EHsc -Zc:preprocessor -Zc:__cplusplus -O2 -Zm200 -std:c++20 -TP -I/cygdrive/d/temp/petsc-3.24.3/include -I/cygdrive/d/temp/petsc-3.24.3/win-vs2026/include -I/cygdrive/c/OPT/Intel/oneAPI/mpi/2021.17/include
mpicxx -show: Unavailable
C++ compiler version: Win32 Development Tool Front End, version 1.11.4 Fri, Sep 10, 2021 6:33:40 PM
Microsoft (R) C/C++ Optimizing Compiler Version 19.50.35723 for x64
-----------------------------------------
Using C/C++ linker: /cygdrive/d/temp/petsc-3.24.3/lib/petsc/bin/win32fe/win32fe_cl
Using C/C++ flags: -GF -MD -wd4996 -Zc:preprocessor -O2
-----------------------------------------
...
...
...
...
...
...
cl : Command line warning D9024 : unrecognized source file type 'win-vs2026\obj\src\tao\unconstrained\impls\owlqn\owlqn.o', object file assumed
cl : Command line warning D9024 : unrecognized source file type 'win-vs2026\obj\src\tao\util\tao_util.o', object file assumed
cl : Command line warning D9024 : unrecognized source file type 'win-vs2026\obj\src\ml\regressor\impls\linear\linear.o', object file assumed
cl : Command line warning D9024 : unrecognized source file type 'win-vs2026\obj\src\ml\regressor\interface\dlregisregressor.o', object file assumed
cl : Command line warning D9024 : unrecognized source file type 'win-vs2026\obj\src\ml\regressor\interface\regressor.o', object file assumed
cl : Command line warning D9024 : unrecognized source file type 'win-vs2026\obj\src\ml\regressor\interface\regressorregi.o', object file assumed
Creating library D:\temp\petsc-3.24.3\win-vs2026\lib\libpetsc.lib and object D:\temp\petsc-3.24.3\win-vs2026\lib\libpetsc.exp
make[3]: Leaving directory '/cygdrive/d/temp/petsc-3.24.3'
make[2]: Leaving directory '/cygdrive/d/temp/petsc-3.24.3'
=========================================
Now to check if the libraries are working do:
make PETSC_DIR=/cygdrive/d/temp/petsc-3.24.3 PETSC_ARCH=win-vs2026 check
=========================================
make PETSC_DIR=/cygdrive/d/temp/petsc-3.24.3 PETSC_ARCH=win-vs2026 checkSymptom: Configure log shows:
Microsoft (R) C/C++ Optimizing Compiler Version 19.50.xxxxx for x86
LINK : fatal error LNK1136: invalid or corrupt file
Solution: You're using 32-bit tools. Use the x64 Native Tools Command Prompt or manually set PATH:
export PATH="/cygdrive/c/Program Files/Microsoft Visual Studio/2026/Community/VC/Tools/MSVC/14.50.xxxxx/bin/Hostx64/x64:$PATH"Symptom: Linker can't find Intel MPI library
Solution:
- Verify Intel MPI is installed
- Check the version number in your path (e.g.,
2021.17vs2021.6) - Update paths in the configure script
Symptom: configure.log ends abruptly during MPI library check
Solution:
- Verify x64 architecture (see above)
- Check that Intel MPI bin directory is in PATH
- Run from x64 Native Tools Command Prompt
Symptom: Cannot find mkl_intel_lp64_dll.lib
Solution:
# Find your actual MKL version
ls /cygdrive/c/OPT/Intel/oneAPI/mkl/
# Update the version in win-vs2026.py
# Change: oamkldir=oadir+'/mkl/YOUR_VERSION/lib'| Option | Description |
|---|---|
--with-cc=cl |
Use MSVC C compiler |
--with-cxx=cl |
Use MSVC C++ compiler |
--with-fc=0 |
Disable Fortran (or use ifort if available) |
--with-debugging=0 |
Optimized build (use =1 for debug) |
--with-blaslapack-lib |
Use Intel MKL for BLAS/LAPACK |
--with-mpi-include |
Intel MPI header location |
--with-mpi-lib |
Intel MPI library location |
--with-64-bit-indices=0 |
Use 32-bit indices (standard) |
--download-f2cblaslapack=1 |
Download Fortran-to-C BLAS/LAPACK if no Fortran compiler |
- Compiler: Must be x64 (64-bit)
- MKL: Uses
lp64variant (64-bit long pointers, 32-bit integers) - MPI: Intel MPI for Windows (x64)
- win32fe: PETSc's wrapper tool (name is historical, works with x64)
Add to your environment:
export PETSC_DIR=/cygdrive/d/temp/petsc-3.24.3
export PETSC_ARCH=win-vs2026
export PATH="$PETSC_DIR/$PETSC_ARCH/lib:$PATH"