https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104631
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Inc is a different class in the shared library and the header if you use -fvisibility=hidden. Since the type of the static variable is hidden still, the variable will be still hidden even if it was marked as default visibilitity. If you want to share Inc across shared libraries and executables, then you need to mark that class as visibility default too.