Suddenly my system can't find `GLIBCXX_3.4.22', "required by swift"

I'm on Linux, in an Ubuntu-based distro. Today I was fiddling around with my Swift binaries to test swiftenv, and suddenly after a fresh install of the Swift 4.1 toolchain, I got this output:

swift build
swift: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.22' not found (required by swift)

I've been trying to fix it for 3-4 hours now. I ran apt-get upgrade among others to see if I needed an update on some library or something like that.

When I query my system to see whether I have the library required, I get this:

felix@felix-X550LD:~$ strings /usr/lib/x86_64-linux-gnu/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
GLIBCXX_3.4.20
GLIBCXX_3.4.21
GLIBCXX_DEBUG_MESSAGE_LENGTH

Somehow I don't have the latest -- GLIBCXX_3.4.22 -- but it's required. My guess is that it isn't available on apt-get yet, maybe? Canonical can be slow to release binaries. But that wouldn't explain how for same version of Swift (this morning it was fine) I got different results. What happened? Were the binaries changed today?

Any help is appreciated.

-- Félix

PS: my OS is ElementaryOS
PPS: I tested it with Swift 4.0 as well.

Solved by adding ppa:ubuntu-toolchain-r/test as a repository. I guess Canonical's stable branches weren't up-to-date enough :man_shrugging:

Just happened the same to me. I also solved it with the ppa:ubuntu-toolchain-r/test repo using this instructions.