Reputation: 10891
Here is my simple test code:
#include <boost/multiprecision/gmp.hpp>
using namespace boost::multiprecision;
int main()
{
gmp_int v = 1;
std::cout << v << std::endl;
return 0;
}
When I try to build and run, I get the following errors:
error: there are no arguments to 'mp_get_memory_functions' that depend on a template parameter, so a declaration of 'mp_get_memory_functions' must be available [-fpermissive]
note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
error: 'mp_get_memory_functions' was not declared in this scope
error: 'mpz_combit' was not declared in this scope
error: 'mp_get_memory_functions' was not declared in this scope|
error: invalid conversion from 'int' to 'const __mpz_struct*' [-fpermissive]
error: cannot bind 'std::ostream {aka std::basic_ostream<char>}' lvalue to 'std::basic_ostream<char>&&'
error: initializing argument 1 of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&&, const _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Tp = boost::multiprecision::backends::gmp_int]'
I am using Code::Blocks. I used precompiled GMP libraries for windows. In code::Blocks I have gmp\lib\libgmp.a
in the linker, gmp\include
in compiler directories and gmp\lib
in linker directories.
Any help would be appreciated in getting GMP to work. I think that I did not install GMP correctly, but it might be a simple issue.
Upvotes: 2
Views: 473
Reputation: 10891
I have solved the issue. I was not linking all my header and library files correctly.
Upvotes: 0
Reputation: 392833
You forgot to use a number adaptor with your gmp_int
backend type:
number<gmp_int> v = 1;
See it Live On Coliru:
#include <boost/multiprecision/gmp.hpp>
#include <iostream>
using namespace boost::multiprecision;
int main()
{
number<gmp_int> v = 1;
std::cout << v << std::endl;
}
Upvotes: 2