strategically dumb
June 5th, 2011, 09:38 PM
I am starting with Ubuntu, and I got Code::Blocks (never used it before) to program in C.
Of course I ran into troubles, and found ways to get things done eventually.
But then I had to use the GMP to handle very large numbers, and there things got so frustrating that I can't even find the words to describe it.
My problem is that when I use this code:
#include <gmp.h>
#include <stdio.h>
int main() {
mpz_t nm,rez ;
mpz_init (nm);
mpz_init(rez);
unsigned long i = 0;
mpz_ui_pow_ui(nm , 2 , 1000);
while (mpz_sgn(nm)) {
i += mpz_mod_ui(rez, nm , 10);
mpz_fdiv_q_ui(nm , nm , 10);
}
return printf("%lu\n" , i);
}the builder says:
8: undefined reference to '__gmpz_init'
9: undefined reference to '__gmpz_init'
12: undefined reference to '__gmpz_ui_pow_ui'
15: undefined reference to '__gmpz_fdiv_r_ui'
16: undefined reference to '__gmpz_fdiv_q_ui'What do I have to copy where to make things work?
Thanks
And yes, I have tried my best, but it's been more than 15 hours and I am stuck here....
Of course I ran into troubles, and found ways to get things done eventually.
But then I had to use the GMP to handle very large numbers, and there things got so frustrating that I can't even find the words to describe it.
My problem is that when I use this code:
#include <gmp.h>
#include <stdio.h>
int main() {
mpz_t nm,rez ;
mpz_init (nm);
mpz_init(rez);
unsigned long i = 0;
mpz_ui_pow_ui(nm , 2 , 1000);
while (mpz_sgn(nm)) {
i += mpz_mod_ui(rez, nm , 10);
mpz_fdiv_q_ui(nm , nm , 10);
}
return printf("%lu\n" , i);
}the builder says:
8: undefined reference to '__gmpz_init'
9: undefined reference to '__gmpz_init'
12: undefined reference to '__gmpz_ui_pow_ui'
15: undefined reference to '__gmpz_fdiv_r_ui'
16: undefined reference to '__gmpz_fdiv_q_ui'What do I have to copy where to make things work?
Thanks
And yes, I have tried my best, but it's been more than 15 hours and I am stuck here....