1

I am an academic and I need to develop some numerical algorithms which require functions from a package called MPIR http://mpir.org/downloads.html. I downloaded the 3.0.0 version and I am trying to figure out how to use this with Visual Studio 2017 in Windows 7 professional. Is there a way to use mpir package with Visual Studio C/C++? Sections 2.4 and 2.5 in this document http://mpir.org/mpir-3.0.0.pdf seems relevant however does not help much.

5
  • You do understand it's written in ANSI C, right? – Ramhound Jul 23 '18 at 4:43
  • So I cannot use it with Visual Studio? Do I have to use cygwin? – 1.. Jul 23 '18 at 4:44
  • I have updated version. I am really naive on this stuff. Usually I have done only elementary C programming from text. – 1.. Jul 23 '18 at 4:47
  • You don't need to know C, to build a project in Visual Studio, and to compile it. – Ramhound Jul 23 '18 at 4:52
  • See instructions for compiling MPIR under Visual Studio: stackoverflow.com/questions/7733707/… – Contango May 23 '19 at 13:00
3

Is there a way to use mpir package with Visual Studio 2017 C/C++?

Yes; Of course you can. You use it like any other C++ interfaces.

All MPIR C language types and functions can be used in C++ programs, since mpir.h has extern "C" qualifiers, but the class interface offers overloaded functions and operators which may be more convenient. Due to the implementation of this interface, a reasonably recent C++ compiler is required, one supporting namespaces, partial specialization of templates and member templates. For GCC this means version 2.91 or later.

Source

As for building it, you need the required MSVC++ installed on your system, but MPIR 3.0.0 specifically supports building it from Visual Studio 2017. Which means the source code as the required solution files.

0
1

If you have vcpkg install it is real simple:

m .\vcpkg install mpir mpir:x64-windows

You get debug, release, x32 and x64 could not be easier. If you do not have vcpkg install you should here is a simple tutorial See the following instructions:

My build looked like the following

Computing installation plan...
The following packages will be built and installed:
    mpir[core]:x64-windows
    mpir[core]:x86-windows
Starting package 1/2: mpir:x64-windows
Building package mpir[core]:x64-windows...
-- Downloading https://github.com/wbhart/mpir/archive/mpir-3.0.0.tar.gz...
-- Extracting source C:/DEV/vcpkg/downloads/wbhart-mpir-mpir-3.0.0.tar.gz
-- Applying patch enable-runtimelibrary-toggle.patch
-- Using source at C:/DEV/vcpkg/buildtrees/mpir/src/mpir-3.0.0-c9f63a8302
-- Building C:/DEV/vcpkg/buildtrees/mpir/x64-windows/build.vc14/dll_mpir_gc/dll_mpir_gc.vcxproj for Release
-- Building C:/DEV/vcpkg/buildtrees/mpir/x64-windows/build.vc14/dll_mpir_gc/dll_mpir_gc.vcxproj for Debug
-- Performing post-build validation
-- Performing post-build validation done
Building package mpir[core]:x64-windows... done
Installing package mpir[core]:x64-windows...
Installing package mpir[core]:x64-windows... done
Elapsed time for package mpir:x64-windows: 2.77 min
Starting package 2/2: mpir:x86-windows
Building package mpir[core]:x86-windows...
-- Using cached C:/DEV/vcpkg/downloads/wbhart-mpir-mpir-3.0.0.tar.gz
-- Using source at C:/DEV/vcpkg/buildtrees/mpir/src/mpir-3.0.0-c9f63a8302
-- Building C:/DEV/vcpkg/buildtrees/mpir/x86-windows/build.vc14/dll_mpir_gc/dll_mpir_gc.vcxproj for Release
-- Building C:/DEV/vcpkg/buildtrees/mpir/x86-windows/build.vc14/dll_mpir_gc/dll_mpir_gc.vcxproj for Debug
-- Performing post-build validation
-- Performing post-build validation done
Building package mpir[core]:x86-windows... done
Installing package mpir[core]:x86-windows...
Installing package mpir[core]:x86-windows... done
Elapsed time for package mpir:x86-windows: 2.016 min

Total elapsed time: 4.786 min
0

Page 18 of your manual says to open the unpacked solution at mpir/build.vc15/mpir.sln and compile the build that you would like to use. There are various optimized builds, but I would start with the general dll_mpir_gc.

This will create libraries. Find the folder that contains the generated .lib files and add it to your project as described in .Lib Files as Linker Input.

2
  • So you open mpir/build.vc15/mpir.sln in Visual Studio and compile with the file I have? Is that all there is to do? – 1.. Jul 23 '18 at 4:59
  • Yes, seems so. There might also be .h header files whose folder also needs to be added to your project. – harrymc Jul 23 '18 at 6:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.