代码之家  ›  专栏  ›  技术社区  ›  bisarch

无法在Solaris 10上使用GCC 5.5包含cmath

  •  4
  • bisarch  · 技术社区  · 6 年前

    我尝试使用gcc5.5.0在solaris10sparc机器上运行以下测试程序

    #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;
    }
    

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

    ~$ 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
    

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

    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;
    

    here

    0 回复  |  直到 6 年前
        1
  •  0
  •   codeDr    6 年前

    我发现了同样的错误。 /opt/csw/lib/gcc/sparc-sun-solaris2.10/5.5.0/include fixed/math.h 我替换了行:

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

    具有

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

    2019年4月24日更新

    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. 
    

    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
    

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

    我对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版本,而不是损坏的系统版本。