/usr/bin/ld: 在尝试 "swift build" Perfect2 项目时找不到 Ubuntu 的 -lstdc++

/usr/bin/ld: cannot find -lstdc++ for Ubuntu while trying to "swift build" Perfect2 project

描述:

我已经按照 Swift3 and Perfect2 的安装步骤进行操作 并且我已经克隆了 Perfect 提出的 PerfectTemplate 测试项目,并且我尝试了 swift build

错误信息:

warning: minimum recommended clang is version 3.6, otherwise you may encounter linker errors. Linking ./.build/debug/PerfectTemplate /usr/bin/ld: cannot find -lstdc++ clang: error: linker command failed with exit code 1 (use -v to see invocation) :0: error: link command failed with exit code 1 (use -v to see invocation) :0: error: build had 1 command failures error: exit(1): /etc/swift301/usr/bin/swift-build-tool -f /home/XXXX/ClionProjects/PerfectTemplate/.build/debug.yaml

我尝试过的:

我已经提出了不同的 SO 问题,这些问题看起来很相似,但都在不同的项目上,并尝试尝试他们的解决方案,但没有成功:

例如:

Matlab Kalman /usr/bin/ld: cannot find -lstdc++

我还注意到来自 clang 版本的警告,我知道我当前的版本是 3.4,但这是通过文档中提到的 sudo apt-get install clang 安装的版本。

我还尝试安装 3.6 版的 clang:sudo apt-get install clang-3.n

然而,当我再次尝试 swift build 后,我收到以下错误:

error: invalid inferred toolchain: could not find clang

问题:

如何消除 /usr/bin/ld: cannot find -lstdc++ 错误,以便构建 PerfectTemplate 项目?

试试这个。它可能行不通,但值得一试。

更新包和依赖项:

sudo apt-get update

然后安装clang 3.6:

sudo apt-get install clang-3.6
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-3.6 100
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.6 100

我希望这有帮助,但如果没有帮助,我们深表歉意。祝你好运!


如果出现这个错误:

/usr/bin/ld.gold: error: cannot open /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../../libstdc++.‌​so: No such file or directory

很可能 libstdc++.so 符号 link 指向一个不存在的文件。

在我的例子中它指向:

/usr/lib/libstdc++.so -> /usr/lib/libstdc++.so.6

这是不正确的,因为 libstdc++.so.6 在该地区不存在。只需通过以下方式找到它的位置:sudo find / -name libstdc++.so.6 这给了我:

/usr/lib/x86_64-linux-gnu/libstdc++.so.6

然后重新创建 link:

sudo rm /usr/lib/libstdc++.so
sudo ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /usr/lib/libstdc++.so

我遇到了同样的问题,update-alternatives 没有帮助我,但是

sudo apt-get update && sudo apt-get upgrade

swift 构建 运行 成功。看起来有些依赖项已被弃用。

sudo apt-get install build-essential