C ++ boost/multiprecision:致命错误:mpfr.h:没有这样的文件或目录 [英] C++ boost/multiprecision: fatal error: mpfr.h: No such file or directory

查看:456
本文介绍了C ++ boost/multiprecision:致命错误:mpfr.h:没有这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已遵循此答案,并使用了示例).

I have followed this answer and used Boost.Multiprecision to use high accuracy floating point numbers (examples).

main.cpp

#include <iostream>
#include <boost/multiprecision/mpfr.hpp>  // Defines the Backend type that wraps MPFR

int main(int argc, char** argv)
{
    namespace mp = boost::multiprecision;     // Reduce the typing a bit later...
    typedef mp::number<mp::mpfr_float_backend<300> >  my_float;
    my_float a, b, c; // These variables have 300 decimal digits precision

    return 0;
}

但是,由于收到以下错误,我在编译此代码时遇到了严重的问题:

However, I have a serious problem for compilation of this code as I receive the following error:

/usr/include/boost/multiprecision/mpfr.hpp:15:18:
              fatal error: mpfr.h: No such file or directory

即使安装 libgmp3-dev

Even installing libgmp3-dev and gmplib did not work.

怎么了?

CMakeLists.txt

CMakeLists.txt

cmake_minimum_required(VERSION 2.8.9)
project (main)

# Libraries
set(Boost_USE_STATIC_LIBS OFF) 
set(Boost_USE_MULTITHREADED ON)  
set(Boost_USE_STATIC_RUNTIME OFF) 
find_package(Boost 1.54.0 COMPONENTS filesystem regex system thread date_time wave) 

if(NOT Boost_FOUND)
    message( FATAL_ERROR "Boost 1.54.0 not found." )
endif()
include_directories(SYSTEM ${Boost_INCLUDE_DIR})

# Flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wfatal-errors -std=c++11")


include_directories(${Boost_INCLUDE_DIRS}) 

# pre executable commands


add_executable(main
    main.cpp
)


# Link
target_link_libraries(main ${Boost_LIBRARIES})
target_link_libraries(main ${CMAKE_THREAD_LIBS_INIT})

推荐答案

如果要使用 MPFR 后端,您必须单独安装它,确保它已构建,并确保其标头位于编译器的INCLUDE路径中,并且其二进制文件(库)位于链接器的命令行中.

If you want to use the MPFR backend you've got to install it separately, make sure it is built, and make sure its headers are in your compiler's INCLUDE path and its binaries (libraries) are in your linker's command line.

(MPFR不是GMP.)

(MPFR is not GMP.)

这篇关于C ++ boost/multiprecision:致命错误:mpfr.h:没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆