I am trying to compile a simple PETSc program (Which works when compiled in Cygwin) in Visual Studio 2019. But I am unable to compile it in VS2019 even after linking all the necessary library files. I have given below the options I have used in VS2019 for compiling petsc program. I see that the compiler is not able to identify the Petsc variables which leads me to believe that I have not done the library linking part properly.
My guide for linking the files is from compiling the program in cygwin using the following command (compiles and run perfectly):
/home/snarayanan1/petsc-release/lib/petsc/bin/win32fe/win32fe.exe ifort -MT -O3 -fpp -I/home/snarayanan1/petsc-release/include -I/home/snarayanan1/petsc-release/arch-ci-mswin-opt-impi/include -I/cygdrive/c/PROGRA~2/Intel/oneAPI/mpi/2021.5.0/include petsc_solver.F90 Test_petsc.F90 -L/cygdrive/c/cygwin64/home/snarayanan1/petsc-release/arch-ci-mswin-opt-impi/lib -L/cygdrive/c/PROGRA~2/Intel/oneAPI/mkl/2022.0.0/lib/intel64 -lpetsc mkl_intel_lp64_dll.lib mkl_sequential_dll.lib mkl_core_dll.lib /cygdrive/c/PROGRA~2/Intel/oneAPI/mpi/2021.5.0/lib/release/impi.lib Gdi32.lib User32.lib Advapi32.lib Kernel32.lib Ws2_32.lib -o Test_petsc
Fortran -> General -> Additional Include Directories:
C:/cygwin64/home/snarayanan1/petsc-release/include; C:/cygwin64/home/snarayanan1/petsc-release/arch-ci-mswin-opt-impi/include; C:/Program Files (x86)/Intel/oneAPI/mpi/2021.5.0/include
Linker -> General -> Additional Library Directories:
C:/cygwin64/home/snarayanan1/petsc-release/arch-ci-mswin-opt-impi/lib; C:/Program Files (x86)/Intel/oneAPI/mkl/2022.0.0/lib/intel64; C:/Program Files (x86)/Intel/oneAPI/mpi/2021.5.0/lib/release
Linker -> Input -> Additional Dependencies:
libpetsc.lib mkl_intel_lp64_dll.lib mkl_sequential_dll.lib mkl_core_dll.lib C:/Program Files (x86)/Intel/oneAPI/mpi/2021.5.0/lib/release/impi.lib Gdi32.lib User32.lib Advapi32.lib Kernel32.lib Ws2_32.lib
This image shows the errors I get
Can someone let me know where I am going wrong (or) direct me to documentation that talks about linking PETSc to visual Studio in detail?
Thank You.
The configurations that you have done look fine to me. The issue you ran into arises from other places.
Try
Fortran Tab: • Preprocessor | Preprocess source files | Yes