How to build Boost V1.57 using the Solaris Studio 12.4 compiler

1.2k views Asked by At

I tried to build Boost V1.57 with the brand new Solaris Studio 12.4 compiler on the Intel Solaris V11.2 platform. I tried to post the errors on the OTN development forum but it turned out that my simple OTN account does not let me add new posts. Hence the question to SO.

Brief summary: 1) Bootstrapping went OK:

cd tools/build
./bootstrap.sh --with-toolset=sun

2) Build command line (note that I put b2 and the compiler in my PATH). This is a "stage" build, i.e. no installation step, just to see that all libraries can be built:

b2 -j2 --build-dir=build toolset=sun address-model=64 threading=multi variant=release  stage >& /tmp/boost_1_57_build.log

Here is a compressed list of errors:

"./boost/archive/binary_iarchive.hpp", line 57: Error: Multiple declaration for adjust_counter.
"./boost/archive/binary_iarchive.hpp", line 57: Error: Unexpected type name "get_counter<boost::archive::binary_iarchive>::type" encountered.
"./boost/archive/binary_oarchive.hpp", line 57: Error: Multiple declaration for adjust_counter.
"./boost/archive/binary_oarchive.hpp", line 57: Error: Unexpected type name "get_counter<boost::archive::binary_oarchive>::type" encountered.
"./boost/archive/detail/register_archive.hpp", line 45: Error: The function "adjust_counter" must have a prototype.
"./boost/archive/detail/register_archive.hpp", line 46: Error: Expression must have a constant value.
"./boost/archive/detail/register_archive.hpp", line 47: Error: Expression must have a constant value.
"./boost/archive/detail/register_archive.hpp", line 48: Error: An integer constant expression is required within the array subscript operator.
"./boost/archive/polymorphic_iarchive.hpp", line 170: Error: Multiple declaration for adjust_counter.
"./boost/archive/polymorphic_iarchive.hpp", line 170: Error: Unexpected type name "get_counter<boost::archive::polymorphic_iarchive>::type" encountered.
"./boost/archive/polymorphic_oarchive.hpp", line 153: Error: Multiple declaration for adjust_counter.
"./boost/archive/polymorphic_oarchive.hpp", line 153: Error: Unexpected type name "get_counter<boost::archive::polymorphic_oarchive>::type" encountered.
"./boost/archive/text_iarchive.hpp", line 136: Error: Multiple declaration for adjust_counter.
"./boost/archive/text_iarchive.hpp", line 136: Error: Unexpected type name "get_counter<boost::archive::text_iarchive>::type" encountered.
"./boost/archive/text_oarchive.hpp", line 121: Error: Multiple declaration for adjust_counter.
"./boost/archive/text_oarchive.hpp", line 121: Error: Unexpected type name "get_counter<boost::archive::text_oarchive>::type" encountered.
"./boost/archive/text_wiarchive.hpp", line 132: Error: Multiple declaration for adjust_counter.
"./boost/archive/text_wiarchive.hpp", line 132: Error: Unexpected type name "get_counter<boost::archive::text_wiarchive>::type" encountered.
"./boost/archive/text_woarchive.hpp", line 146: Error: Multiple declaration for adjust_counter.
"./boost/archive/text_woarchive.hpp", line 146: Error: Unexpected type name "get_counter<boost::archive::text_woarchive>::type" encountered.
"./boost/archive/xml_iarchive.hpp", line 146: Error: Multiple declaration for adjust_counter.
"./boost/archive/xml_iarchive.hpp", line 146: Error: Unexpected type name "get_counter<boost::archive::xml_iarchive>::type" encountered.
"./boost/archive/xml_oarchive.hpp", line 135: Error: Multiple declaration for adjust_counter.
"./boost/archive/xml_oarchive.hpp", line 135: Error: Unexpected type name "get_counter<boost::archive::xml_oarchive>::type" encountered.
"./boost/archive/xml_wiarchive.hpp", line 152: Error: Multiple declaration for adjust_counter.
"./boost/archive/xml_wiarchive.hpp", line 152: Error: Unexpected type name "get_counter<boost::archive::xml_wiarchive>::type" encountered.
"./boost/archive/xml_woarchive.hpp", line 142: Error: Multiple declaration for adjust_counter.
"./boost/archive/xml_woarchive.hpp", line 142: Error: Unexpected type name "get_counter<boost::archive::xml_woarchive>::type" encountered.
"./boost/math/cstdfloat/cstdfloat_types.hpp", line 378: Error: The type "boost::STATIC_ASSERTION_FAILURE<0>" is incomplete.
"/opt/solarisstudio12.4/lib/compilers/include/CC/stlport4/stl/_algo.c", line 436: Error: The function "lrand48" must have a prototype.
"/usr/include/stdlib.h", line 113: Error: putenv(char*) was declared before with a different language.
"libs/atomic/src/lockpool.cpp", line 74: Error: "}" expected instead of ",".
"libs/context/src/unsupported.cpp", line 7: Error: #error "platform not supported".
"libs/log/src/date_time_format_parser.cpp", line 399: Error: Linker scopes may not change after symbol definition.
"libs/log/src/date_time_format_parser.cpp", line 412: Error: Linker scopes may not change after symbol definition.

IMO any decent C++ compiler should be able to build Boost as I can hardly imagine any serious C++ project without the Boost libraries. So I am just wondering if a Boost or Solaris Studio developer reads this and helps me with some patches...

Many thanks for any hints!

1

There are 1 answers

1
dmr195 On

The first thing to know about building Boost with Solaris Studio is that the Jam file hasn't been updated for over 5 years and uses STLport as its C++ standard library. This may not be what you want. Solaris Studio 12.4 can be run in C++11 mode where it uses the GNU libstdc++ to provide its standard library. Even if you're running in the default C++03 mode, you'd probably want to use the Apache C++ standard library. If you're not using STLport for the rest of your C++ code then ask another question about changing the Boost Jam files for Solaris Studio to use a different standard library.

Moving on to the exact error messages you're seeing, I think all the ones in the archive library have the same cause, and it's easy to fix. Edit boost/archive/detail/register_archive.hpp and change line 31 from:

#ifdef __SUNPRO_CC

to:

#if 0

A long time ago somebody added a workaround for a bug in an old version of Solaris Studio, but now Solaris Studio 12.4 finds the workaround code to be invalid but can cope with the code all the other compilers see.

For the "platform not supported" message from the context library you're out-of-luck if you're on Solaris, but maybe it doesn't matter if you're not using this particular Boost library.

The "Linker scopes may not change after symbol definition" errors are caused by an attempt to use Solaris symbol visibility directives. I think the Boost developers would be best off taking these out given that they no longer test on Solaris, because the default visibility is global and at least that works. To make all symbols global and avoid these problems, edit boost/config/compiler/sunpro_cc.hpp and delete these lines:

//
// Dynamic shared object (DSO) and dynamic-link library (DLL) support
//
#if __SUNPRO_CC > 0x500
#  define BOOST_SYMBOL_EXPORT __global
#  define BOOST_SYMBOL_IMPORT __global
#  define BOOST_SYMBOL_VISIBLE __global
#endif

and also edit libs/math/build/Jamfile.v2 and delete this line:

<toolset>sun:<cxxflags>-xldscope=hidden

For the last few errors you pasted more context is needed to see where they come from.