如何在 Windows 上为 Dev-C++ 安装 C++ 库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27620580/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 20:50:08  来源:igfitidea点击:

How to Install a C++ library on Windows for Dev-C++

c++windowsinstallgmp

提问by Flexico

I downloaded a library called GMP(it's for doing calculations with arbitrarily large numbers) and I can't figure out how to actually install and use it. All of the instructions I find tell me to run the files configure, MakeFile, and install, but when I try to do that I get 'install' is not a recognized internal or external command.

我下载了一个名为GMP(它用于对任意大数进行计算)的库,但我不知道如何实际安装和使用它。我找到的所有说明都告诉我运行文件configure, MakeFile, 和install,但是当我尝试这样做时,我得到了'install' is not a recognized internal or external command.

All I can figure is that the instructions are for Linux, but I'm running Windows. I found a couple of instructions here on SO that tell me to copy certain files into the Dev-C++ folder, but I can't find the files specified. I've never had to install a library like this before, so I'm really lost.f

我所能想到的是,这些说明是针对 Linux 的,但我运行的是 Windows。我在这里找到了一些关于 SO 的说明,告诉我将某些文件复制到 Dev-C++ 文件夹中,但我找不到指定的文件。我以前从来没有安装过这样的库,所以我真的迷路了。f

回答by Grzegorz Szpetkowski

If you have latest version of Dev-C++, that ships with MinGW-w64 (as its native environment), then you may download pre-builded package of GMP from here. After that all you have to do is:

如果您有最新版本的 Dev-C++,随 MinGW-w64(作为其本机环境)一起提供,那么您可以从这里下载预构建的 GMP 包。之后,您所要做的就是:

  1. Create simple C++ console project.
  1. 创建简单的 C++ 控制台项目。

Here is some basic main.cppfile:

这是一些基本main.cpp文件:

#include <cstdio>
#include <gmp.h>

int main(int argc, char** argv) {
    mpz_t n;

    mpz_init_set_str(n, "1234567890", 0);

    gmp_printf("%Zd\n", n);

    mpz_clear(n);

    return 0;
}
  1. Unpack archive
  2. Copy gmp.hheader into Dev-Cpp\MinGW64\x86_64-w64-mingw32\include
  3. Copy libgmp.dll.ainto MinGW64\x86_64-w64-mingw32\lib
  4. Copy libgmp-10.dllshared library into Dev-Cpp\MinGW64\bin
  5. Edit properties of your project, add -lgmpflag into Linker (look for Parameters tab)
  6. Compile & Run
  1. 解压存档
  2. gmp.h标题复制到Dev-Cpp\MinGW64\x86_64-w64-mingw32\include
  3. 复制libgmp.dll.aMinGW64\x86_64-w64-mingw32\lib
  4. libgmp-10.dll共享库复制到Dev-Cpp\MinGW64\bin
  5. 编辑项目的属性,将-lgmp标志添加到链接器(查找参数选项卡)
  6. 编译运行

If you want other version or C++ interface, then you need to find existing build or try to compile it under MinGW environment.

如果你想要其他版本或C++接口,那么你需要找到现有的构建或尝试在MinGW环境下编译它。