Compiling in Windows

From OSUPDOCS
Jump to navigation Jump to search

This page explains how to compile code engines using Windows.

Using Visual Studio

Development of NairnMPM and NairnFEA in Windows is best done using Visual Studio. The first step is to install Visual Studio, and a free version is available called "Visual Studio Community 2015" (these notes are based on this version of Visual Studio, but the changes for any future versions should be minor). You can download this IDE from:

https://www.visualstudio.com/vs/community/

Be sure to customize to get VC++ for C++ development. The download is large (15-20 GB depending on options selected) and will take a while. See Mac/Windows Requirements for additional installations that might be needed for development in Windows.

Installing Xerces

Before you can compile and run the project, however, you will need a compiled version of the xerces-c_#_#.dll library (where #_# is version number) and a copy of the xerces header files. These needed components are installed as follows:

  1. Got to the xerces web site.
  2. Go to "Download" section and get source distribution zip file, which contains VS projects (these notes used version 3.1.4; some more recent versions do not have VS projects, but you can get 3.1.4, or maybe a newer one with projects, from the download archives).
  3. Extract the contents of the zip file and place the resulting xerces folder in the same folder as the GitHib folder that contains the nairn-fea-mpm project folder. For OSParticulas, put the xerces folder in the same folder as the OSParticulas project folder.
  4. Open the Visual Studio solution in xerces project folder at projects\Win32\VC14\xerces-all\xerces-all.sln (be sure not to open the xerces-all file one level higher, because it does not work). This step is using "VS14" because it corresponds to the version supplied with "Visual Studio Community 2015" (and works with "Visual Studio 2019" with automatic update). This number may change if new "Visual Studios" are made available.
  5. After loaded, select the XercesLib project.
  6. Select "Release" target for "x64" platform in the tool bar (these instructions assume you want 64-bit builds, which are recommended).
  7. Build the project. The compiled xerces-c_3_1.dll file will be written to Build\Win64\VC14\Release in the xerces folder (numbers may change if xerces version number changes).

Compile NairnMPM, NairnFEA, and other tools

To compile all code binaries in Visual Studio:

  1. Open the Visual Studio solution at Common\Projects\VS\NairnMPM\NairnMPM.sln in the nairn-fea-mpm project.
  2. To compile NairnMPM, NairnFEA, ExtractMPM, and CompareGlobal, click on each project and select to build that project from the Build menu.
  3. The compiled results will be in the Common\Projects\VS\NairnMPM\Build\Release-x64 folder. If the compile fails, see below.

The above builds will fail if you are using a different version of Visual Studio and/or different version of Windows. They may also fail if the project cannot find xerces header files or the xerces library file. Here are some project settings you may need to customize to work on your computer::

  1. Click on the project you are compiling (e.g., NairnMPM) and then select Project→Properties... menu command (or right click the project and pick "Properties" from the pop-up menu).
  2. Clock on General and:
    • Set Target Platform and Target Platform Version to work on your computer
    • Set Platform Toolset to one available on your computer
  3. Click on "VC++ Directories" and change the xerces entry in "Include Directories" to point to src folder in the downloaded xerces project on your computer. The checked-out project assumes the xerces folder is in the same folder as the checked out nairn-fea-mpm folder, but you can store it elsewhere if you prefer.
  4. Expand "Linker" section, click on "General," and change the xerces entry in "Additional Library Directories" to be path on your computer to the folder with the compiled xerces library.
  5. Repeat for other projects as needed.

You should now be able to build NairnMPM and NairnFEA code engines and the results will be in the Common\Projects\VS\NairnMPM\Build\Release-x64 folder. See Options for Running Calculations to start running calculations. You can also build the ExtractMPM and CompareGlobal tools and their executable will be in the same output folder.

Windows Development

To run the compiled code, you need to provide all the required dlls. You can move them all to any folder, but it is convenient to keep then in the build folder at Common\Projects\VS\NairnMPM\Build\Release-x64. The needed dll files are

  1. xerces-c_3_1.dll - this dllis created when you build xerces.
  2. vsruntime140.dll and msvcp140.dll - these dlls are to run compiled C++ code and can be copied from the Visual Studio Redist folder. Be sure to get the x64 versions.
  3. vcomp140.dll - this dll is for OpenMP to run in parallel and can be copied from the Visual Studio Redist folder. Be sure to get the x64 versions.

Using Eclipse IDE or cygwin

While it might be possible to compile using Eclipse, the process is no longer supported. Similarly, use of cygwin is no longer supported. The method was cumbersome and the compiled executables run much more slowly then when compiled using Visual Studio. Windows compiling should use Visual Studio.