-3

I have absolutely no idea about using gmp. Need some functions for a project and need a quick installation guide. I am Absolutely beginner to this field so please help accordingly.

I have:

  • Dev C++ 5.4.2 in windows 8.1 configuration with GCC4.7.2 as default compiler.
  • gmp-static-mingw-4.1.tar

Please specify the correct procedure to configure gmp library.

Paras Rautela
  • 56
  • 1
  • 7
  • 2
    This really isn't suited for SO because it doesn't involve any actual code, but a configuration problem. – Drew McGowen Jul 23 '14 at 18:15
  • 1
    I have no clue about gmp-static-mingw-4.1.tar contents but I would : copy gmp.h in your includes path (maybe in a gmp directory), and libgmp.a in your libraries path ? – willll Jul 23 '14 at 18:51
  • @willll tried copying headers and libraries already but even the sample program couldn't run... – Paras Rautela Jul 23 '14 at 19:07
  • @ParasRautela : refine your question with your issue ! – willll Jul 23 '14 at 20:10

1 Answers1

1

At first put gmp.h into ..\Dev-Cpp\MinGW32\include and both libgmp.a and libgmp.la into ..\Dev-Cpp\MinGW32\lib directory, then create some project in DevCpp, for example:

#include <stdio.h>
#include <gmp.h>

int main(void)
{
    mpz_t x;

    mpz_init(x);
    mpz_set_str(x, "12345", 10);
    mpz_mul_ui(x, x, 2);

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

    mpz_clear(x);
    return 0;
}

After that go to Project Options -> Parameters and click Add Library of Object:

enter image description here

From the list select libgmp.a file (your static library) and click Open:

enter image description here

Compile and run you project, you will see some note about Makefile update, simply confirm. enter image description here

Note that GMP 4.1 is now rather old, consider latest version and/or manual compilation for best possible performance on your configuration.

Grzegorz Szpetkowski
  • 36,988
  • 6
  • 90
  • 137