无法在Solaris 10上使用GCC 5.5包含cmath [英] Unable to include cmath using GCC 5.5 on Solaris 10

查看:104
本文介绍了无法在Solaris 10上使用GCC 5.5包含cmath的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用gcc 5.5.0在我的Solaris 10 sparc计算机上运行以下测试程序

I am trying to run the following test program on my Solaris 10 sparc machine using gcc 5.5.0

#include <iostream>
#include <cmath>

int main()
{
    std::cout << "exp2(4) = " << std::exp2(4) << '\n'
              << "exp2(0.5) = " << std::exp2(0.5) << '\n'
              << "exp2(-4) = " << std::exp2(-4) << '\n';
    return 0;
}

以下是操作系统的详细信息,

Here are the OS details,

~$ uname -a
SunOS sovms577 5.10 Generic_147147-26 sun4v sparc SUNW,SPARC-Enterprise-T5220
~$ cat /etc/release 
                   Oracle Solaris 10 1/13 s10s_u11wos_24a SPARC
  Copyright (c) 1983, 2013, Oracle and/or its affiliates. All rights reserved.
                            Assembled 17 January 2013

在使用以下命令进行编译时,

On compiling using the following command,

g++ -std=c++11 -Wall test.cpp

我收到以下错误消息,

In file included from /opt/csw/include/c++/5.5.0/cmath:44:0,
                 from test.cpp:2:
/opt/csw/lib/gcc/sparc-sun-solaris2.10/5.5.0/include-fixed/math.h:52:12: error: ‘std::float_t’ has not been declared
 using std::float_t;
            ^
/opt/csw/lib/gcc/sparc-sun-solaris2.10/5.5.0/include-fixed/math.h:53:12: error: ‘std::double_t’ has not been declared
 using std::double_t;
            ^
/opt/csw/lib/gcc/sparc-sun-solaris2.10/5.5.0/include-fixed/math.h:55:12: error: ‘std::fpclassify’ has not been declared
 using std::fpclassify;
            ^
/opt/csw/lib/gcc/sparc-sun-solaris2.10/5.5.0/include-fixed/math.h:56:12: error: ‘std::isfinite’ has not been declared
 using std::isfinite;

我按照此处给出的说明安装了GCC 5.5.

I installed GCC 5.5 following the instructions given here.

推荐答案

我发现了相同的错误. 在标题/opt/csw/lib/gcc/sparc-sun-solaris2.10/5.5.0/include-fixed/math.h 中 我替换了该行:

I found the same error. In the header /opt/csw/lib/gcc/sparc-sun-solaris2.10/5.5.0/include-fixed/math.h I replaced the line:

#if __cplusplus >= 201103L
using std::float_t;

使用

#if 0 && __cplusplus >= 201103L
using std::float_t;

更新2019年4月24日-@Andrew Henle希望您知道

Update 24 Apr 2019 -- @Andrew Henle wants you to know

If you are attempting to compile C++11 on an unpatched, unupdated 
installation of Solaris 10, and are presenting this as a "fix", 
you do not understand what you are doing. 

@Andrew Henle说有一个"solaris"补丁可修复csw/include/c ++/.../cmath和csw/lib/gcc/..../math.h,但该补丁如何影响安装的csw标头中的未知和未指定.

@Andrew Henle says there's a 'solaris' patch that fixes the csw/include/c++/.../cmath and csw/lib/gcc/..../math.h, but how that patch affects the installation of the csw headers is unknown and unspecified.

更新2019年4月26日

我使用以下软件包使用csw gcc安装程序构建了新的binutils和gcc-5.5.0:

I built a new binutils and gcc-5.5.0 using the csw gcc installation using the following packages:

binutils-2.27.tar.bz2
cloog-0.18.1.tar.gz
gcc-5.5.0.tar.gz
gmp-5.1.2.tar.xz
mpc-1.0.1.tar.gz
mpfr-3.1.2.tar.xz

首先构建binutils.

Build binutils first.

../configure --prefix=$TARGET_PATH/sx64
make
make install

我为gcc使用了以下配置:

I used the following config for gcc:

../configure --prefix=$TARGET_PATH/sx64 --enable-languages=c,c++ --enable-threads=posix --enable-version-specific-runtime-libs --disable-libsanitizer --with-as=$TARGET_PATH/sx64/bin/as --with-ld=$TARGET_PATH/sx64/bin/ld --with-gnu-ld --with-gnu-as
make bootstrap
make install

您必须使用--with-as和--with-ld来使gcc使用内置的binutils版本而不是损坏的系统版本.

You have to use --with-as and --with-ld to get gcc to use the binutils version built instead of the broken system versions.

使用该编译器,我可以编译有效的c ++-11代码没有问题.

Using this compiler I had no issues compiling valid c++-11 code.

这篇关于无法在Solaris 10上使用GCC 5.5包含cmath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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