如何在 Windows 上为 Dev-C++ 安装 C++ 库 [英] How to Install a C++ library on Windows for Dev-C++

查看:44
本文介绍了如何在 Windows 上为 Dev-C++ 安装 C++ 库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下载了一个名为 GMP 的库(用于对任意大数进行计算),但我不知道如何实际安装和使用它.我找到的所有指令都告诉我运行文件 configureMakeFileinstall,但是当我尝试这样做时,我得到 'install' 不是可识别的内部或外部命令.

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.

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

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

推荐答案

如果你有最新版本的 Dev-C++,附带 MinGW-w64(作为它的原生环境),那么你可以下载 GMP 的预构建包来自 此处.之后你所要做的就是:

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:

  1. 创建简单的 C++ 控制台项目.

这是一些基本的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. 解压存档
  2. gmp.h 头复制到 Dev-Cpp\MinGW64\x86_64-w64-mingw32\include
  3. libgmp.dll.a复制到MinGW64\x86_64-w64-mingw32\lib
  4. libgmp-10.dll 共享库复制到Dev-Cpp\MinGW64\bin
  5. 编辑项目的属性,将 -lgmp 标志添加到链接器(查找参数选项卡)
  6. 编译&运行
  1. Unpack archive
  2. Copy gmp.h header into Dev-Cpp\MinGW64\x86_64-w64-mingw32\include
  3. Copy libgmp.dll.a into MinGW64\x86_64-w64-mingw32\lib
  4. Copy libgmp-10.dll shared library into Dev-Cpp\MinGW64\bin
  5. Edit properties of your project, add -lgmp flag into Linker (look for Parameters tab)
  6. Compile & Run

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

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

这篇关于如何在 Windows 上为 Dev-C++ 安装 C++ 库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆