简体   繁体   中英

Port C++14 Linux application to Solaris 10 and 11

Currently porting an existing c++ linux application to Solaris 10 and 11 (First x86 then SPAARC).

Started with installing gcc5g++ on solaris 10 and started compilation. Got errors in math.h and found out that, it is a bug in the version of g++5.5 which I installed. Because of this bug I get errors like


/opt/csw/lib/gcc/i386-pc-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/i386-pc-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/i386-pc-solaris2.10/5.5.0/include-fixed/math.h:56:12: error: 'std::isfinite' has not been declared using std::isfinite; ^


Since my application has used c++14 constructs which g++ 4.92 doesn't support fully. Need a later version of g++ (above 5.5)

I couldn't find any packages from where I can install later version of g++ on Solaris 10, hence I used a Solaris 11 machine installed g++ 7.3 trying to execute the executable generated on Solaris 11 to Solaris 10 I get the following error:


ld.so.1: hellod: fatal: libc.so.1: version 'SUNWpublic' not found (required by file /Desktop/hellod) ld.so.1: hellod: fatal: libc.so.1: open failed: No such file or directory Killed


Questions

  • Is there any other methods to solve the errors which I am facing ?
  • Can I compile on Solaris 11 and make it work on Solaris 10 ?
  • What are the other methods to install Later versions on g++ on Solaris 10 ?
  • What are the other alternatives which I can cross compile / port this application ?

Thank full to any help and pointers related to this topic.

First, to support later C++ standards, your Solaris 10 installation needs to be up-to-date. See Unable to include cmath using GCC 5.5 on Solaris 10 for an example of why. Read the comments - there are patches that need to be applied to Solaris 10 to make it compliant with C++11, and presumably C++14.

In general you can't compile on Solaris 11 and run the resulting binary on Solaris 10.

The good thing is, you should be able to compile on Solaris 10 and run just fine on Solaris 11, so you won't have to maintain two separate environments nor ship two separate Solaris products. You'll want to test this with your binaries, but in theory it should work - and in my experience, it does work.

I can't find any later versions (later than 5-something) for Solaris 10, so you'll probably have to bootstrap your own version of GCC 7-something or later. See https://unix.stackexchange.com/questions/446760/how-to-build-a-gcc-4-9-0-successfully-on-solaris-10-sparc for an example of building GCC 4.9.0 on Solaris 10 SPARC. Note that GCC support for Solaris 10 is likely to end soon, per this posting: https://gcc.gnu.org/ml/gcc/2018-10/msg00139.html :

Therefore I think it's time to obsolete support for that version in GCC 9, thus removing it in GCC 10.

I haven't built GCC on Solaris 10 in quite a few years, so I don't know what you may run into building GCC 7 or 8.

Another possible alternative is to use Oracle Developer Studio instead of GCC. Version 12.6 supports C++14 and is available for both Solaris 10 and 11.

One caveat - however you compile, you'll almost certainly want to statically link both libgcc and libstdc++ , especially if you compile your own GCC.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM