GCC Error Keeps Hugo from Starting on CentOS 7

hugo does not start because of a gcc error

* This page contains promotional content

When I installed the latest version of Hugo on CentOS7, it would no longer start because of the error below

./hugo version
./hugo: /lib64/libstdc++.so.6: version GLIBCXX_3.4.20' not found (required by ./hugo) ./hugo: /lib64/libstdc++.so.6: version GLIBCXX_3.4.21’ not found (required by ./hugo)

Checking the GCC version

# strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBCXX_3.4.14
GLIBCXX_3.4.15
GLIBCXX_3.4.16
GLIBCXX_3.4.17
GLIBCXX_3.4.18
GLIBCXX_3.4.19

It looks like the GCC version on CentOS is still old

Solution

  • I think it would work if you installed a newer GCC from source, but that may break the gcc dependencies on CentOS, so I do not recommend it unless you are very knowledgeable.
  • Compile and build Hugo from source (this one is safe)
    Install golang+ gcc-c++ on CentOS7 beforehand
    I used to describe the approach of downloading from source, but pulling it straight from git looks easier
$ vim from-gh.sh
mkdir $HOME/src
cd $HOME/src
git clone https://github.com/gohugoio/hugo.git
cd hugo
go install --tags extended

$ sh from-gh.sh

Once the build finishes without trouble, hugo is generated inside the folder specified by GOPATH (if you do not specify one, ~/go/), so

$ ~/go/bin/hugo version
hugo v0.82.0-DEV+extended linux/amd64 BuildDate=unknown

If you can confirm that extended is shown, you are fine.
If the build seems to fail, please also have a look at Hugo source build errors on CentOS7 .

  • If neither of the two items above works
    Just install the Hugo that does not have extended.
    However, it will not work with themes that support SASS/SCSS.

Incidentally, on the latest ubuntu and debian I confirmed the extended version works without touching anything.

For reference, the only difference with the Extended version is whether SASS/SCSS is supported.

See also