xiaowanmay / googletest

Automatically exported from code.google.com/p/googletest
0 stars 0 forks source link

1.5.0 (pre) doesn't compile by default with Sun Studio 12.1 on Solaris #278

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago

What steps will reproduce the problem?
1. Get the Subversion source for 1.5.0 (rev 417)
2. Install Sun Studio 12.1 for OpenSolaris
3. Set BASH environment "export CC=cc CXX=CC" (make sure cc and CC point to
SunStudio C and C++)
4. In the gtest source directory, type 'cmake .'

What is the expected output? What do you see instead?
This is supposed to run.  Instead, it gives the following compilation error
(summarized):

".../include/gtest/internal/gtest-param-util-generated.h", line 61: Error:
iterator_traits is not a member of std
...
".../include/gtest/gtest-param-test.h", line 279: Error: iterator_traits is
not a member of std.

What version of Google Test are you using? On what operating system?
gtest subversion 143 (1.5.0 pre) on OpenSolaris snv_134 (2010.3 pre)

Please provide any additional information below, such as a code snippet.

It appears that the problem is that gtest now uses the 'iterator_traits'
STL feature.  By default, this is not enabled in Sun Studio because of
backwards compatibility issues.  

As a work-around, it is possible to use the '-library=stlport4' CXXFLAG to
tell Sun Studio to enable iterator_traits:

 export CC=cc CXX=CC CXXFLAGS='-library=stlport4'
 cmake .

After making this change, gtest_unittest successfully runs 352 tests (with
13 tests disabled).

It would be much nicer if gtest could find a way to enable this by default.
 This could be done by finding a way to add the -library=stlport4 CXXFLAG
whenever the CMake or Autotools system detects that the compiler is Sun Studio.

(Note: This probably applies to all versions of Sun Studio and to Solaris 10.)

Original issue reported on code.google.com by Matthew....@gmail.com on 16 Apr 2010 at 7:28

GoogleCodeExporter commented 9 years ago
Hady- as our Solaris expert at large, can you please comment on this bug? Do 
you see this in your setup?

Original comment by vladlosev on 16 Apr 2010 at 10:06

GoogleCodeExporter commented 9 years ago
Well, I don't see this in my setup cause I also set -library-stlport4 in my 
CXXFLAGS...

I hesitated at first about adding the option to the CMakeLists.txt, but had 
finally 
decided that the option shouldn't be forced on the user. There are many out 
there that 
build with non-standard STLs like stlport5, stdcxx, etc...

Original comment by hady.za...@gmail.com on 19 Apr 2010 at 4:22

GoogleCodeExporter commented 9 years ago
If there isn't a good way to make this into a code or configuration fix, could 
it be
a documentation fix?  I know Solaris isn't an officially supported target, but 
it
would still be useful to have this information readily available somehow, 
perhaps in
a README.solaris file or something, for all the Solaris users who are going to 
use
gtest anyway.

Original comment by Matthew....@gmail.com on 19 Apr 2010 at 4:51

GoogleCodeExporter commented 9 years ago
Vlad, can we add an FAQ entry for this to the wiki?  Thanks.

Original comment by w...@google.com on 19 Apr 2010 at 9:03

GoogleCodeExporter commented 9 years ago
Matthew, what are the exact command sequences - both for CMake and for 
Autotools?

Original comment by vl...@google.com on 20 Apr 2010 at 5:09

GoogleCodeExporter commented 9 years ago
The important part is to set the environment up:

export CC=cc CXX=CC CXXFLAGS='-library=stlport4'

After that, it's just a matter of running either cmake . or ./configure.  This 
works,
assuming that SunStudio is mapped to the cc and CC commands.

Original comment by Matthew....@gmail.com on 21 Apr 2010 at 7:41

GoogleCodeExporter commented 9 years ago
FAQ updated in rev 419.

Original comment by vladlosev on 22 Apr 2010 at 11:02