Solaris SunStudio 12.4 Standard Library related issue

I am trying to compile a sample from boost-asio on Solaris-10 using SunStudio 12.4. Compiling with GCC 4.9.2 works, but down the line I need support for both compilers, so it won't be easy to switch.

CC output -V: CC: Sun C++ 5.13 SunOS_sparc 2014/10/20

Compilation line: (for each cpp file)

CC -m32 -std=c++11 -I./asio-1.10.6/include -I./boost/include/boost-1_58 -c *.cpp -o *.o

Linker line: (note that * .o is actually a list of all previously created object files)

CC -m32 -L./boost/sparc/sun/release32/lib *.o -o httpServer -lCrun -lCstd -lxnet -lboost_system


I am getting a bunch of unresolved symbols for standard library stuff (like string, ios_base, locale, etc.). I've posted linker errors here .

I strongly suspect this is related to use -std=c++11

. I included this option due to a compilation issue with iterator_traits

. Despite iterator_traits

not being a C ++ 11 feature, for some reason SunStudio cannot compile it unless it compiles in C ++ 11 mode. Error regarding iterator_traits


Error: iterator_traits is not a member of std.

The code that is causing this compilation failure is in boost boost/detail/iterator.hpp

. What follows is the code.

// (C) Copyright David Abrahams 2002.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at

#ifndef ITERATOR_DWA122600_HPP_
#define ITERATOR_DWA122600_HPP_

// This header is obsolete and will be deprecated.

#include <iterator>

namespace boost

namespace detail

using std::iterator_traits;
using std::distance;

} // namespace detail

} // namespace boost

#endif // ITERATOR_DWA122600_HPP_


Other things that include and use this header generate errors like Error: iterator_traits is not a member of boost::detail

and then other syntax errors because it now thinks all of the following code is invalid.

Other things I've tried:

  • Adding -lC to -lCrun (linker cannot find this library)
  • Adding -lc (similar problem).
  • Checked in SUNWspro / libs directory and found and exist.
  • Entering -lCstd before -lCrun

Other (less relevant) Information:

  • The asio sample in question is httpServer (I find this in the server directory in the examples)

source to share

1 answer

From Docs:

In C ++ 11 mode, the CC compiler uses the g ++ ABI and the g ++ version that ships with Oracle Solaris Studio. For this release, version 4.8.2 of the g ++ runtime library.

ABI describes low-level details in generated object code. Modules that use different ABIs cannot be successfully linked together in a program. This means that you must use C ++ 11 mode for all modules in your program, or none of them .

So with that said, you should also specify "-std = c ++ 11" for the linker phase. You are not doing this now.



All Articles