GMP Compile Error

Discussion in 'C++' started by recurphy@yahoo.com, May 31, 2004.

  1. Guest

    I tried to use GMP on a Unix machine, but received errors. What should I do?

    C++ Code:
    #include <iostream>
    #include <gmp.h>

    int
    main ()
    {
    mpz_t z;
    mpz_init (z);
    cin >> z;
    cout << z << endl;
    }

    Command:
    g++ gmp.cpp

    Message:
    Undefined first referenced
    symbol in file
    __gmpz_init /var/tmp/ccvV4wON.o
    __ls__FR7ostreamPC12__mpz_struct /var/tmp/ccvV4wON.o
    __rs__FR7istreamP12__mpz_struct /var/tmp/ccvV4wON.o
    ld: fatal: Symbol referencing errors. No output written to a.out
    collect2: ld returned 1 exit status
    , May 31, 2004
    #1
    1. Advertising

  2. Rolf Magnus Guest

    wrote:

    > I tried to use GMP on a Unix machine, but received errors. What
    > should I do?


    I have no idea what "GMP" is, but it looks to me as if you forgot to
    link your program against the library that provides "GMP".
    Rolf Magnus, May 31, 2004
    #2
    1. Advertising

  3. wrote:
    > I tried to use GMP on a Unix machine, but received errors. What should I do?
    >
    > C++ Code:
    > #include <iostream>
    > #include <gmp.h>
    >
    > int
    > main ()
    > {
    > mpz_t z;
    > mpz_init (z);
    > cin >> z;
    > cout << z << endl;
    > }
    >
    > Command:
    > g++ gmp.cpp
    >
    > Message:
    > Undefined first referenced
    > symbol in file
    > __gmpz_init /var/tmp/ccvV4wON.o
    > __ls__FR7ostreamPC12__mpz_struct /var/tmp/ccvV4wON.o
    > __rs__FR7istreamP12__mpz_struct /var/tmp/ccvV4wON.o
    > ld: fatal: Symbol referencing errors. No output written to a.out
    > collect2: ld returned 1 exit status


    You probably need to link the gmp library ...

    g++ gmp.cpp -l<gmp lib>
    Gianni Mariani, May 31, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. anonymous
    Replies:
    0
    Views:
    489
    anonymous
    Sep 26, 2003
  2. Replies:
    4
    Views:
    1,105
  3. Nagaraj
    Replies:
    1
    Views:
    854
    Lionel B
    Mar 1, 2007
  4. Allen Harkleroad
    Replies:
    0
    Views:
    459
    Allen Harkleroad
    Sep 5, 2007
  5. dot
    Replies:
    0
    Views:
    3,401
Loading...

Share This Page