Next: , Previous: , Up: Installing MPIR   [Index]


2.4 Building with Microsoft Visual Studio

MPIR can be built with the professional and higher versions of Visual Studio 2012, 2013, 2015 and 2017. It can also be built with the community editions of Visual Studio 2015 and 2017. If the assembler optimised versions of MPIR are required, then both Python 3 and the YASM assembler also need to be installed. MPIR can also be built with the Intel C/C++ compiler that can be integrated into versions of Visual Studio.

Python 3 can be obtained from:

https://www.python.org/

and the YASM assembler from:

http://yasm.tortall.net/Download.html

This assembler (vsyasm.exe, NOT yasm.exe) should be placed in the directory C:\Program Files\yasm.

Alternatively vsyasm.exe can be placed elsewhere provided that the environment variable ‘YASMPATH’ gives its location.

Building MPIR

A build of MPIR is started by double clicking on the file mpir.sln in the appropriate sub-directory within the MPIR root directory:

    Visual Studio 2012:  mpir/build.vc11/mpir.sln
    Visual Studio 2013:  mpir/build.vc12/mpir.sln
    Visual Studio 2015:  mpir/build.vc14/mpir.sln
    Visual Studio 2017:  mpir/build.vc15/mpir.sln

Visual Studio will then display a list of individual build projects from which an appropriate version of MPIR can be built. For example, a typical list of projects is:

    dll_mpir_gc     standard DLL, no assembler (win32 and x64)
    dll_mpir_p3     assembly optimised DLL for pentium 3 (win32)
    lib_mpir_p3     assembly optimised static library for 
                    pentium 3 (x64)
    lib_mpir_core2  assembly optimised static library for 
                    core2 (x64)
    dll_mpir_core2  assembly optimised DLL for core2 (x64)

MPIR can be built either as a static library or as a DLL. A DLL will include both the C and C++ features of MPIR but a static library will include only the C features so in this case the project:

  lib_mpir_cxx     the MPIRXX C++ static library (win32 and x64)

should also be built to provide the MPIR C++ static library (‘MPIRXX’).

Before a project is built, Visual Studio should be set to the required configuration (Release or Debug) and the required target architecture (win32 or x64). The build process puts the output files into one of the two sub-directories:

mpir/lib 
mpir/dll 

depending on whether static library or DLL versions have been built.

Additional Assembler Optimised Versions

The Visual Studio builds for MPIR are initially provided with a small set of assembler optimised projects but many more are available and can be obtained by running the Python program mpir_config.py <N> that is in the mpir\build-vc directory. The value of <N> required depends on the version of Visual Studio in use as follows:

    Visual Studio 2012:  11
    Visual Studio 2013:  12
    Visual Studio 2015:  14
    Visual Studio 2017:  15

This program, which has to be run before Visual Studio, provides a list of all the assembler optimised versions of MPIR that are available. Any number of versions can be chosen and these builds will then be available when Visual Studio is subsequently opened by double clicking on mpir.sln.

Testing Visual Studio versions of MPIR

Testing a version of the library once it has been built is started by double clicking on the appropriate solution file:

    Visual Studio 2012:  mpir/build.vc11/mpir-tests.sln
    Visual Studio 2013:  mpir/build.vc12/mpir-tests.sln
    Visual Studio 2015:  mpir/build.vc14/mpir-tests.sln
    Visual Studio 2017:  mpir/build.vc15/mpir-tests.sln

The tests are always run on the last version of MPIR built and it is important that the configuration set for building the tests (Release or Debug, win32 or x64) is the same as that used to build MPIR. When testing the static library versions of MPIR, both the C (mpir.lib) and C++ (mpirxx.lib) must be built. After loading there will be a large list of test projects starting:

  Solution `mpir-tests' (202 projects)
        add-test-lib 
        bswap
        constants
        ....

The project ‘add-test-lib’ should be selected and built first, after which the solution as a whole (i.e. the first line shown above) can be selected to build all the tests. After the build has completed, the tests are run by executing the Python program run-tests.py in the appropriate Visual Studio build sub-directory, for example, for Visual Studio 2017:

   mpir/build.vc15/mpir-tests/run-tests.py 

Next: Notes for Particular Systems, Previous: Notes for Package Builds, Up: Installing MPIR   [Index]