Bug #714

problem compiling with Sun Studio - visibility

Added by Pavel Heimlich over 8 years ago. Updated over 3 years ago.

Status:ClosedStart date:23 Jul 2010
Priority:NormalDue date:
Assignee:Robin Mills% Done:


Target version:0.26


On OpenSolaris b134 with the Sun Studio 12u1 compiler, the build of exiv2 0.20 fails with
"error.hpp", line 97: Error: Identifier expected instead of "__attribute__".

This is because the use of attribute ((visibility(x)) is not part of the C++ standard, it's gcc specific and not supported by sun studio.

The attached patch worked for me.


exiv2-visibility.diff Magnifier - patch (976 Bytes) Pavel Heimlich, 23 Jul 2010 14:29

exiv2-visibility.diff Magnifier - patch (519 Bytes) Pavel Heimlich, 31 Jan 2012 13:39

Related issues

Related to Exiv2 - Feature #536: Switch to a unified build system based on cmake Closed
Related to Exiv2 - Bug #710: Problems Compiling Exiv2 Under SGI IRIX Closed 29 Jun 2010
Related to Exiv2 - Bug #715: -funsigned-char breaks build with Sun Studio Closed 23 Jul 2010

Associated revisions

Revision 2300
Added by Andreas Huggel over 8 years ago

#714: Extended C++ symbol visibility support for Sun Studio C++ compiler.


#1 Updated by Andreas Huggel over 8 years ago

Hi Pavel,

Thanks for reporting this issue. Assuming you configure your system with the ./configure script, for the patch to have any effect, the EXV_HAVE_GXXCLASSVISIBILITY compiler define must be set. That's the case if the visibility support is not explicitely disabled with the --disable-visibility configure option and if the compiler has a -fvisibility-inlines-hidden option (see below).

Does the Sun compiler indeed have this option?

AC_MSG_CHECKING([whether to enable g++ visibility support])
    [  --disable-visibility    do not use g++ visibility support ],
if test "$GXX_VISIBILITY" = "yes"; then
    if test "$GXX_VISIBILITY" = "yes"; then
        CXXFLAGS="${CXXFLAGS} -fvisibility=hidden -fvisibility-inlines-hidden" 
    if test "$enable_shared" = "yes"; then

#2 Updated by Pavel Heimlich over 8 years ago

studio does not have the -fvisibility* options, however it may ignore them, so I guess that's how the HAVE_GXXCLASSVISIBILITY parameter got enabled.
The equivalent flag to fvisibility-hidden is -xldscope=hidden

from what I gathered, -fvisibility-inlines-hidden does not have an equivalent in Studio

#3 Updated by Andreas Huggel over 8 years ago

  • Category set to build
  • Target version set to 0.21
  • % Done changed from 0 to 50

Checked-in generalized visibility support which should now also work with the Sun Studio compiler. It sets the compiler defines according to the patch and sets the -xldscope=hidden flag if supported.

Appreciate if you can test this and let me know if it works.


PS: This also needs to be implemented in the cmake build scripts.

#4 Updated by Andreas Huggel over 8 years ago

  • Target version deleted (0.21)

#5 Updated by Andreas Huggel over 8 years ago

  • Target version set to 1.0

#6 Updated by Pavel Heimlich about 7 years ago

I tried v0.22 with Solaris11 and Solaris Studio 12.3 and the Studio detection code is incomplete.
First, it only works for the C compiler (cc defines __SUNPRO_C, CC defines __SUNPRO_CC).
Second, the version condition is not really necessary as all currently supported (and available for download) Studio versions do support __global.

I had to use the attached patch to build exiv2 0.22

#7 Updated by Robin Mills over 3 years ago

  • Category changed from build to not-a-bug
  • Status changed from New to Closed
  • Assignee set to Robin Mills
  • Target version changed from 1.0 to 0.26

This is an unsupported compiler. Please see the comments in #710 concerning compiler and platform support.

#8 Updated by Robin Mills over 3 years ago

  • % Done changed from 50 to 100

Also available in: Atom PDF

Redmine Appliance - Powered by TurnKey Linux