Visual Studio Compile MPIR Method section

Visual Studio Compile MPIR Method section

MPIR is a numerical computing library for high-precision computing, providing support for large integers and high-precision rational numbers.

MPIR is a project derived from GMP. Compared with everyone's heard of GMP, GMP is a set of highly optimized arbitrary precision numerical calculation library. Many well-known software uses GMP internally, such as gcc. But GMP has a problem, that is, it contains a lot of assembly code, which cannot be compiled under the MSVC platform. To this end, the MPIR and MPFR projects were born. The work done by these two projects is basically to port GMP to the MSVC platform, and there are not many other changes.

Of course, the goal of MPIR is to be cross-platform, and it can also be compiled and run on Linux and Mac OS X.

This blog mainly talks about how to compile MPIR under the MSVC platform.

First download from the official website: http://www.mpir.org/
The current version is 3.0.0

The version of MSVC I use is VS2015.
In addition to this, python 3 and yasm are used.

python 3 can be downloaded from https://www.python.org/ .

yasm is downloaded from http://yasm.tortall.net/Download.html .
Depending on the operating system version, select

  • Win32 VS2010 .zip (for use with VS2010+ on 32-bit Windows)
  • Win64 VS2010 .zip (for use with VS2010+ on 64-bit Windows)

Download one of these two. Then put vsyasm.exe in the C:\Program Files\yasm directory.

mpir provides project files of various versions of VS, the corresponding relationship is as follows:

  • 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

After opening a vs sln file multiple projects will appear.

title illustrate
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)

The dll projects in these projects contain the interfaces of c and c++. The lib project has only c interface.

If you need to compile the static library with C++ interface, you need to compile the lib_mpir_cxx project, which only has C++ interface.

In addition to the few listed above, there are also four such as dll_mpir_haswell_avx dll_mpir_skylake_avx, which are relatively new processors from Intel. If your computer is the corresponding processor, you can compile these versions, otherwise it is useless.

Also, I recommend changing the compiled dll and lib filenames. Right-click on the project name and select Properties from the pop-up menu. The following dialog box will appear. You can change the name according to the position indicated in the picture below.
write picture description here

Then compile them one by one. I didn't compile dll_mpir_p3 successfully here, everything else is fine.

The next blog will describe how this library is used.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325561574&siteId=291194637