gpt4 book ai didi

c++ - 如何在 visual studio 上为 C++ 安装 MPFR 和 GMP

转载 作者:行者123 更新时间:2023-11-30 02:51:30 28 4
gpt4 key购买 nike

据我了解,我应该先安装 GMP。我为此找到的唯一教程是 http://cs.nyu.edu/exact/core/gmp/当我到达第 3 步时:“打开 gmp.dsw(VC++.Net 的 gmp.vcproj)以构建 GMP”,我遇到了很多构建错误。您可以在这里下载:http://www.f2h.co.il/msbz68nzzip .有很多错误,如“ fatal error C1083:无法打开包含文件:'fib_table.h':没有这样的文件或目录”。

还有其他教程吗?我该怎么办?

我在 Windows 7 上使用 Visual Studio 2010。

最佳答案

如何使用 MPFR 设置 Visual Studio 2015 项目

本指南将帮助您使用一些预构建的二进制文件使用 MPFR 和 MPIR(GMP 的 Windows 端口)启动并运行 VS 项目。 (这里是一个 VS 项目的链接和我提到的下载的二进制文件:https://www.dropbox.com/s/p08cw59bic4f02v/MPFR-VSProj.zip?dl=1)

获取预编译的二进制文件

  • 从以下位置获取预编译文件:http://www.holoborodko.com/pavel/mpfr/#projects

    • mpfr_mpir_x86_x64_msvc2010(使用 MSVC 2010 预编译的 mpfr mpir

      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(Holoborodko 的 c++ 包装器)

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

Visual Studio 项目设置:

  1. 将配置更改为“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. 在 $(SolutionDir)(顶级目录,其中解决方案被保留。
  3. 将正确的文件复制到这些文件夹中:
    • mpfr_mpir_x86_x64_msvc2010:
      • 来自 mpfr 和 mpir 的“Win32 > Release”文件夹
      • 将*.dll、*.exp、*.lib 和*.pdb 复制到$(SolutionDir)/lib 目录
      • 所有头文件到 $(SolutionDir)/include 目录
    • mpfrc++-3.6.2
      • 将 mpreal.h 添加到您的项目中(如果您愿意,也可以添加到 $(SolutionDir)/include 中)
      • C++ 包装器只需要 header
  4. 告诉 VS 去哪里寻找新创建的“include”和“lib”目录

    Configuration Properties > VC++ Directories

    • Include Directories: add path to your include directory
    • Library Directories: add path to your lib directory
  5. 链接库的 *.lib 文件

    Configuration Properties > Linker > Input > Additional Dependencies

    • Add the following to this list: mpfr.lib; mpir.lib;
  6. 使用编译器选项,更改运行时库:

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

    • select "Multi Threaded DLL (/MD)"
  7. 为build设置编译器参数:

    Configuration Properties > Debugging > Command Arguments

    • append: "-lmpfr -lgmp"
  8. 强制将 DLL 复制到输出目录

    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. 告诉 VS 在清理输出文件夹时清理 DLL:

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

    • add: '*.dll'
  10. 要测试您的项目,请从“example/example.cpp”复制 main()mpfrc++-3.6.2文件夹

    • 确保在包含 stdafx.h 之后添加包含您的 mpreal.h 文件

有用的 SO 文章:

关于c++ - 如何在 visual studio 上为 C++ 安装 MPFR 和 GMP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19688442/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com