By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,232 Members | 1,612 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,232 IT Pros & Developers. It's quick & easy.

GMP Compile Error

P: n/a
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
Jul 22 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
re******@yahoo.com 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".

Jul 22 '05 #2

P: n/a
re******@yahoo.com 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>
Jul 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.