Skip to content

Instantly share code, notes, and snippets.

@shiyuning
Last active March 15, 2024 14:46
Show Gist options
  • Save shiyuning/867d5af0a3a6345b50ec1b193a71e4be to your computer and use it in GitHub Desktop.
Save shiyuning/867d5af0a3a6345b50ec1b193a71e4be to your computer and use it in GitHub Desktop.
Install MM-PIHM on Windows using Visual Studio

Install MM-PIHM on Windows using Visual Studio

Prerequisites

Compiling MM-PIHM on Windows requires CMake and Visual Studio. Compiling MM-PIHM requires CMake version higher than 3.1.3. For Visual Studio, please use Visual Studio 2017.

Install CVODE

  1. In MM-PIHM/cvode directory, create two separate folders, builddir and instdir
  2. Open a Visual Studio Command Prompt and cd to builddir
  3. Run cmake-gui ../
    1. Hit Configure

    2. Uncheck BUILD_SHARED_LIBS and EXAMPLES_INSTALL

    3. Change CMAKE_INSTALL_PREFIX to ../instdir

    4. Set other options as desired

    5. Hit Generate

      Cmake configuration

  4. Back in the VS Command Window
    1. Run msbuild ALL_BUILD.vcxproj
    2. Run msbuild INSTALL.vcxproj

The resulting libraries will be in the instdir. The sundials project can also now be opened in Visual Studio. Double click on the ALL_BUILD.vcxproj file to open the project. Build the whole solution to create the sundials libraries.

Install MM-PIHM

Note: the following procedures have been tested using Visual Studio 2017. Visual Studio 2019, however, will report errors using the following instruction.

  1. Open Visual Studio and create a new Console App project. Choose a project name as you desire

  2. Add corresponding source files

  3. In Configuration properties->C/C++/General, add additional include directories src/include; cvode/instdir/include

    VS include directories

  4. In Configuration properties->C/C++/Preprocessor, add preprocessor definition _CRT_SECURE_NO_WARNINGS, and other preprocessor definition (e.g., _NOAH_ for Flux-PIHM, etc.). Note that you may need to remove some files unrelated to your module from your workspace. For example, you will need to remove RT and BGC source files if you only want to compile Flux-PIHM.

    VS preprocessor definition

  5. In Linker->Input, add additional dependencies XXX\MM-PIHM\cvode\instdir\lib\sundials_cvode.lib and XXX\MM-PIHM\cvode\instdir\lib\sundials_nvecserial.lib

    VS additional dependencies

  6. Build your project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment