开发者

undefined reference,gmp lib

I installed the gmp libraries in cygwin via its installer. I tried to compile a simple program with gcc.

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


int
main(void)
{
    mpz_t test;
    int i;

    printf("enter number\n");
    gmp_scanf("%Z",&test);
    gmp_printf("test=%Z",test);
    i=mpz_probab_prime_p(test,5);
    if(i)
        printf("prime\n");
    else
        printf("not prime\n");
    return 0;
}

But I got this:

 /cygdrive/c/Users/xxxxx/Documents/NetBeansProjects/rsa_system/main.c:13: undefined reference to  `__imp____gmp_scanf'

This is the first time that I try to开发者_StackOverflow中文版 use a non-standard library and I'm getting confused here. My compiler is set to Cygwin and I've done all the installation part. Any ideas on what may be wrong? Thank you.


Are you asking gcc to link GMP?

i.e.: gcc -lgmp main.c ....

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜