gpt4 book ai didi

c++ - gmp_int boost 错误

转载 作者:塔克拉玛干 更新时间:2023-11-03 06:43:24 26 4
gpt4 key购买 nike

这是我的简单测试代码:

#include <boost/multiprecision/gmp.hpp>

using namespace boost::multiprecision;

int main()
{
gmp_int v = 1;
std::cout << v << std::endl;

return 0;
}

当我尝试构建和运行时,出现以下错误:

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]'

我正在使用 Code::Blocks。我为 Windows 使用了预编译的 GMP 库。在 code::Blocks 中,我在链接器中有 gmp\lib\libgmp.a,在编译器目录中有 gmp\include,在 gmp\lib 中链接器目录。任何有助于使 GMP 发挥作用的帮助将不胜感激。我认为我没有正确安装 GMP,但这可能是一个简单的问题。

最佳答案

您忘记将数字适配器与您的 gmp_int 后端类型一起使用:

number<gmp_int> v = 1;

查看 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;
}

关于c++ - gmp_int boost 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25149781/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com