Compile problem

Mike Mohr akihana at
Wed Sep 10 02:12:02 UTC 2014


mpz_set_ui is just like any other C subroutine; it takes an opaque data
type (mpz_t) and a regular unsigned long as parameters.  On a typical
server platform, an unsigned long integer can hold values from 0 to just
over 4.2 billion.  The number you've supplied is over 20 orders of
magnitude larger than the capacity of an unsigned long.  Of course it won't
work.  And then you've forgotten to link the program with libgmp.


On Tue, Sep 9, 2014 at 9:28 AM, Artyom Mkhitaryan <art.mhtr at>

> Good evening! I installed GMP on my ubuntu  but have some problems
> compiling my program like:
> gmp.c: In function ‘main’:
> gmp.c:9:18: warning: integer constant is too large for its type [enabled by
> default]
> gmp.c:9:2: warning: large integer implicitly truncated to unsigned type
> [-Woverflow]
> /tmp/ccf6qFcG.o: In function `main':
> gmp.c:(.text+0x11): undefined reference to `__gmpz_init'
> gmp.c:(.text+0x25): undefined reference to `__gmpz_set_ui'
> gmp.c:(.text+0x31): undefined reference to `__gmpz_clear'
> program was like:
> #include <stdlib.h>
> #include <stdio.h>
> #include <gmp.h>
> #include <string.h>
> int main (int argc, char **argv) {
>     mpz_t numb;
>     mpz_init(numb);
>     mpz_set_ui(numb,99999999999999999999999999999999);
>     nmpz_clear(numb);
>     return 0;
> }
> Could you please help me?
> _______________________________________________
> gmp-bugs mailing list
> gmp-bugs at

More information about the gmp-bugs mailing list