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

≯℡__Kan透↙ 提交于 2019-12-19 09:37:52

问题


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.

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


回答1:


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. Create simple C++ console project.

Here is some basic main.cpp file:

#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.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

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



来源:https://stackoverflow.com/questions/27620580/how-to-install-a-c-library-on-windows-for-dev-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!