Compilation Guide for INMOST with PETSc linear solvers
INMOST may be configured with optional PETSc support. In this case INMOST will support calling linear solvers from PETSc package, i.e. you will be able to activate Solver::PETSc package in Solver::Solver constructor.
Below presented minimalistic guide that uses only Visual Studio compiler and Microsoft MPI library.
Install Cygwin. When prompted to install Cygwin packages check Devel and Python packages to be installed.
In Windows Start menu search for Visual Studio Command Prompt or Visual Studio Win64 Command Prompt, depending on whether you want to generate 32-bit or 64-bit binaries.
From there run
or if your Cygwin installation path is different
Type and run cl command from appeared console, it should not complain that it cannot find any shared libraries.
Type export PATH="/usr/bin:$PATH" command in console. This will let you use Cygwin binaries. Notice that '/usr/bin' should go first, this will make Cygwin binaries prefferable over binaries with matching names.
To avoid conflict between link.exe executables in Cygwin and Visual Studio run command mv /usr/bin/link.exe /usr/bin/link-cygwin.exe. At the end we should not forget to return it back so that Cygwin will be still usable.
Now switch to the petsc_source_dir directory. Type bin/win32fe/win32fe.exe cl it should return you some information on which flags can be passed to Visual Studio compiler. We just check that it works.
Now for win32fe.exe to be accessable from console type export PATH="$PATH:`pwd`/bin/win32fe". Check that you can run win32fe from console
Now we will run PETSc configure script. We will have to tell it where to find Microsoft MPI library. Typically it is installed to "C:\Program Files\Microsoft HPC Pack 2012\". Assuming this folder is correct type the command to run PETSc configuration script:
Please note that there are also flags provided for compilers. First -O2 flag tells compiler to optimize everything, then -MD tells which runtime library should be used. It is very important that runtime libraries match across all of your libraries, otherwise your final executable will not compile or running it will result in segmentation faults or heap corruption which will be really hard to resolve. Flag for runtime library provided here should match with flag in your final application as well as flag in INMOST library. The -wd4996 flag suppress specific compiler warning from output.
Be patient since configuration script takes quite a time. Once finished, PETSc script will provide you with some information on build options.
Copy and enter make command with PETSC_ARCH and PETSC_DIR as script output suggests you. You have to wait quite a while again while PETSc library is being built. Once finished, it will suggest you to run tests.
Fill free to skip this tests. Now you have finished with Cygwin, run command mv /usr/bin/cygwin-link.exe /usr/bin/link.exe to reverse changes we made before and you may close Cygwin console.
Now open Notepad where you have memorized two variables: PETSC_DIR and PETSC_ARCH, which were told to you by PETSc configuration script. If you have not memorized them then go to petsc_source_directory open configure.log and search for those variables.
Open cmake-gui, switch to INMOST build directory and activate USE_SOLVER_PETSC checkbox.
Then click "Add Entry" button and add following entries:
PETSC_DIR of type PATH path to the directory of petsc source code
PETSC_ARCH of type STRING describing platform for which PETSc was built
If you have installed Cygwin not in standard location (It is normally installed to "c:\cygwin" or "c:\cygwin64") then you will have to provide
CYGWIN_INSTALL_PATH type PATH with the path to the directory where you have installed cygwin.
Now hit "Configure". Wait some time while PETSc run some tests and decide on compilable configuration. It should succeed at last.
Now click "Generate", reopen Visual Studio with INMOST library and rebuild it.
Please note that the cmake script for PETSc package that is used here was modified in order to handle spaces in names and correctly resolve required Cygwin executables. If you encounter any problem you can visit https://github.com/jedbrown/cmake-modules/ page and replace