3

As I understand, I should first install GMP. The only tutorial I found for this purpose is http://cs.nyu.edu/exact/core/gmp/ and when I reach step 3: "Open gmp.dsw (gmp.vcproj for VC++.Net) to build GMP" I get many building errors. You can download it here: http://www.f2h.co.il/msbz68nzzip. There are many errors like "fatal error C1083: Cannot open include file: 'fib_table.h': No such file or directory".

Is there an other tutorial? What should I do?

I'm using Visual Studio 2010 on Windows 7.

4

3 回答 3

3

How to set up Visual Studio 2015 Project with MPFR

This guide will help you get up and running with a VS project using MPFR and MPIR (a Windows port of GMP) using some prebuilt binaries. (Here is a link to a VS project and the downloaded binaries I mention: https://www.dropbox.com/s/p08cw59bic4f02v/MPFR-VSProj.zip?dl=1)

Getting the Precompiled Binaries

  • Get the pre-compiled files from: http://www.holoborodko.com/pavel/mpfr/#projects

    • mpfr_mpir_x86_x64_msvc2010 (precompiled mpfr mpir with MSVC 2010

      Since it was compiled with MSVC 2010, it needs Microsoft Visual C++ 2010 * Redistributable. If we try to run the program in Debug mode, we won't be able to. we'll get this error: "The program cant't start becaue MSVCP100.dll is missin from your computer". Essentially, MSVCP100.dll is part of the Visual Studio 2010 install but not in the Redistributable, which only contains the dlls needed for release versions of builds

      • NOTE: visual studio still allows one to debug in the Release configuration so debugging isn't a big issue at this stage when you are just trying to get up and running
    • mpfrc++-3.6.2 (c++ wrapper by Holoborodko)

      NOTE: these binaries are a few years old but they are tested and "relatively bug-free"

Visual Studio project settings:

  1. Change the Configuration to "Release, x86"

    This is necessary to get going for now since we are missing the debug dlls in the 2010 Redistributable (should have been installed as part of VS install)

  2. Create a 'libs' and 'include' folder in the $(SolutionDir) (top level dir where the solution is kept.
  3. Copy over the right files into these folders:
    • mpfr_mpir_x86_x64_msvc2010:
      • From 'Win32 > Release' folders for mpfr and mpir
      • Copy *.dll, *.exp, *.lib and *.pdb to $(SolutionDir)/lib directory
      • All header files to the $(SolutionDir)/include directory
    • mpfrc++-3.6.2
      • Add mpreal.h to your project (or in $(SolutionDir)/include if you prefer)
      • The header is all you need for the c++ wrapper
  4. Tell VS where to look for the newly created 'include' and 'lib' directories

    Configuration Properties > VC++ Directories

    • Include Directories: add path to your include directory
    • Library Directories: add path to your lib directory
  5. Link the lib's *.lib files

    Configuration Properties > Linker > Input > Additional Dependencies

    • Add the following to this list: mpfr.lib; mpir.lib;
  6. Using compiler options, change the runtime library:

    Configuration Properties > C/C++ > Code Generation > Runtime Library

    • select "Multi Threaded DLL (/MD)"
  7. Set the compiler arguments for building:

    Configuration Properties > Debugging > Command Arguments

    • append: "-lmpfr -lgmp"
  8. Force the DLLs to get copied to the output directory

    Configuration Properties > Build Events > Post-Build Event

    • Command Line: 'XCOPY "$(SolutionDir)lib*.dll" "$(TargetDir)" /D /K /Y'
    • Description: 'Copy DLLs to Target Directory'
    • Use in Build: YES
  9. Tell VS to clean up the DLLs when it cleans up an output folder:

    Configuration Properties -> General -> Extensions to Delete on Clean

    • add: '*.dll'
  10. To Test your project, copy over the main() from "example/example.cpp" from the mpfrc++-3.6.2 folder

    • Make sure to add an include your mpreal.h file after your stdafx.h include

Helpful SO Articles:

于 2016-07-04T02:36:00.477 回答
0

I met similar problem and had just resolved it by download precompiled MPIR and MPFR libraries instead of GMP which needs mingw or similar on Windows.

Here is the link of my solution: How to install MPFR with Visual studio 2008 /2010

Hope this help

Now a perfect solution by @casevh can be found here: Build mpir/mpfr/mpc via VC++

于 2013-10-31T23:54:12.460 回答
0

using VCPKG package management system should solve your pain. Most of my use of GNU libs etc under windows is solved in this way.

于 2020-01-16T10:37:30.647 回答