Please forgive my ignorance… I only use Solaris for testing C/C++ libraries I have an interest in. I'm not a Solaris admin or Solaris user.
I installed GCC-5 on Solaris 11.3, x86 because I needed a C++ compiler that supports -std=c++11
(see below for the package output). Sun's native GCC is 4.8, and it does not support C++11 well (or at all).
Unfortunately, I cannot find it after the install:
$ g++-5 --version
-bash: g++-5: command not found
$ sudo find /usr -name gcc-5
$ sudo find /bin -name gcc-5
$
And for completeness:
$ /bin/gcc --version
gcc (GCC) 4.8.2
...
$ ls -l /usr/bin/gcc
lrwxrwxrwx 1 root root 18 Jun 7 2016 /usr/bin/gcc -> ../gcc/4.8/bin/gcc
$ which gcc-5
no gcc-5 in /usr/local/bin /usr/local/sbin /bin /sbin /usr/bin /usr/sbin /usr/sfw/bin
Where is the compiler located?
According to Installing GCC on Oracle Solaris 11 on Stack Overflow, its supposed to be in /usr/bin/gcc
as a symlink. But the answer appears to be off a bit:
$ /usr/bin/gcc --version
gcc (GCC) 4.8.2
...
According to GCC missing from Solaris 11, and server already deployed on Server Fault:
/usr/sfw/bin
is the bundled gcc path with Solaris 10. On Solaris
11.1, gcc is, when installed, directly available in/usr/bin
as a symlink that points to/usr/gcc/<version>/bin/gcc
The answer appears to be off a bit, too.
$ sudo pkg install --accept gcc-5
------------------------------------------------------------
Package: pkg://solaris/release/evaluation@1.0,5.12-5.12.0.0.0.115.0:20170111T175931Z
License: evaluation
This software has been made available for evaluation purposes only.
See http://www.oracle.com/technetwork/server-storage/solaris11/technologies/foss-evaluation-program-2586275.html for further information.
Packages to install: 2
Create boot environment: No
Create backup boot environment: No
DOWNLOAD PKGS FILES XFER (MB) SPEED
Completed 2/2 8/8 0.0/0.0 17.4k/s
PHASE ITEMS
Installing new actions 37/37
Updating package state database Done
Updating package cache 0/0
Updating image state Done
Creating fast lookup database Done
Updating package cache 2/2
After installing gcc-5
:
$ find / -name 'gcc*' 2>/dev/null
/usr/share/vim/vim73/compiler/gcc.vim
/usr/share/gcc-4.8.2
/usr/share/man/man1/gcc.1
/usr/gcc
/usr/gcc/4.8/bin/gcc-nm
/usr/gcc/4.8/bin/gcc-ranlib
/usr/gcc/4.8/bin/gcc
/usr/gcc/4.8/bin/gcc-ar
/usr/gcc/4.8/lib/gcc
/usr/gcc/4.8/lib/gcc/i386-pc-solaris2.11/4.8.2/plugin/include/ada/gcc-interface
/usr/gcc/4.8/lib/gcc/i386-pc-solaris2.11/4.8.2/plugin/include/gcc-plugin.h
/usr/gcc/4.8/share/locale/de/LC_MESSAGES/gcc.mo
/usr/gcc/4.8/share/locale/ja/LC_MESSAGES/gcc.mo
/usr/gcc/4.8/share/locale/fr/LC_MESSAGES/gcc.mo
/usr/gcc/4.8/share/locale/zh_CN/LC_MESSAGES/gcc.mo
/usr/gcc/4.8/share/locale/zh_TW/LC_MESSAGES/gcc.mo
/usr/gcc/4.8/share/locale/es/LC_MESSAGES/gcc.mo
/usr/gcc/4.8/share/gcc-4.8.2
/usr/gcc/4.8/share/info/gccinstall.info
/usr/gcc/4.8/share/info/gccint.info
/usr/gcc/4.8/share/info/gcc.info
/usr/gcc/4.8/share/man/man1/gcc.1
/usr/bin/gcc
/usr/local/share/emacs/24.5/lisp/cedet/semantic/bovine/gcc.el
/usr/local/share/emacs/24.5/lisp/cedet/semantic/bovine/gcc.elc
/usr/include/gc/atomic_ops/sysdeps/gcc
/usr/include/avahi-common/gccmacro.h
/usr/include/pulse/gccmacro.h
/export/home/jwalton/botan/src/scripts/ci/circle/gcc-sanitizer.sh
/export/home/jwalton/botan/src/scripts/ci/circle/gcc-static-debug.sh
/export/home/jwalton/botan/src/scripts/ci/circle/gcc-shared-debug.sh
/export/home/jwalton/botan/src/build-data/cc/gcc.txt
/export/home/jwalton/zlib-1.2.8/contrib/gcc_gvmat64
/opt/developerstudio12.5/lib/compilers/CC-gcc/lib/gcc
/opt/developerstudio12.5/lib/compilers/CC-gcc/gcc_version.map
/opt/solarisstudio12.4/lib/compilers/CC-gcc/gcc_version.map
/opt/solarisstudio12.4/lib/compilers/CC-gcc/lib/gcc
And:
~$ pkg search -l gcc | grep ^basename
basename dir opt/developerstudio12.5/lib/compilers/CC-gcc/lib/gcc pkg:/developer/developerstudio-125/library/studio-gccrt@12.5-1.0.0.0
basename dir opt/solarisstudio12.4/lib/compilers/CC-gcc/lib/gcc pkg:/developer/solarisstudio-124/library/studio-gccrt@12.4-1.0.0.0
basename dir usr/include/gc/atomic_ops/sysdeps/gcc pkg:/library/gc@7.2-0.175.2.0.0.39.0
basename link usr/bin/gcc pkg:/developer/gcc-4/gcc-c-48@4.8.2-0.175.3.0.0.30.0
basename file usr/gcc/4.8/bin/gcc pkg:/developer/gcc-4/gcc-c-48@4.8.2-0.175.3.0.0.30.0
pkg: Search performance is degraded.
Best Answer
TL;DR:
and try again.
So the issue is that
gcc-5
is what's known as a "group" package. That is, it consists (at least primarily) of a bunch ofgroup
dependencies. Agroup
dependency is one that will be installed if possible, but ignored if not. In this case, it was not possible to install one or more of the dependencies ofgcc-5
, so they were ignored, and you ended up with less than you expected.When that happens (whether it's fewer packages, or packages at a different version), the first thing you should do is tell
pkg
what you actually expect. (Now, the disconnect here is how to know what to expect; without knowing how to inspectgcc-5
for that information, or even knowing that you might have to, I'm not sure how to answer that.) In this case, choose one of its dependencies to see if it helps; say,gcc-c-5
(you followed this step forgcc-c++-5
, which gave you the same problem as I show here, but I wanted to put it all together in one answer). This tellspkg
not to ignore its inability to installgcc-c-5
, but to actually complain in detail about why it couldn't be installed. Hopefully there will be something in the output to give us a clue about what to do next:When you get a mess of solver output like this, you typically want to look for the deepest-indented issue and see if you can correct that. In this case, you see that it's unable to install
gcc-c-runtime@5.4.0-5.12.0.0.0.115.0
because it's excluded by an installed incorporation.Perhaps a digression is necessary: what's an incorporation? Like a group package, it's a package that primarily delivers dependencies, in this case,
incorporate
dependencies. These dependencies never actually cause packages to be installed; they simply place constraints on packages that may be installed. Specifically, incorporatingfoo@1.2
means that iffoo
is installed, it must be in the version range[1.2, 1.3)
; that is, a minimum of1.2
(inclusive), and a maximum of1.3
(exclusive), or anything that matches1.2.x.y.z....
.In this case, the incorporation
userland-incorporation
that's already installed on the system has placed a constraint ongcc-c-runtime
that's incompatible with the version ofgcc-c-runtime
that installinggcc-c-5
requires.That's where we run into one of the oddities of the Solaris FOSS evaluation program. The packages made available there are not well integrated with the rest of the system; they're designed to be installed on a newer version of Solaris. But they've been built such that the system can at least be sanely massaged into letting them be installed. In this case, you have to change a few facets.
Most of the FOSS packages in Solaris are incorporated in such a way that the constraint delivered by that
incorporate
dependency can be relaxed. You can do that by changing the facet named byversion-lock.<pkg-name>
tofalse
. In this case,gcc-c-runtime
andgcc-c++-runtime
are the two packages blocking the installation you want, so (as above):This will give a bit of output, but not seemingly do much. Once it's done, though, we can try again:
And voila, we get a bunch of packages installed, which actually contain stuff. From here, you should now be able to type
gcc --version
and see that it is indeed 5.4.0. Note also that the two packages whose facets we unlocked got upgraded, a possibility available after the unlocking.You might ask why we didn't need to unlock any other facets. The reason for that is that Solaris 11.3 didn't deliver GCC 5, and so didn't deliver any constraints on its package versions. So all the
gcc-*-5
packages are already unconstrained, and needn't be unlocked in order to relax constraints.You might notice that the
gcc-gfortran-runtime
andgcc-gobjc-runtime
packages got installed at their 4.8 versions. That's because they're still constrained, but nothing we did conflicted with those constraints. For consistency, you probably should unlock them as well, and then upgrade them to their 5.x versions (or, if you've gotten this far before trying anything, just unlock them from the start).