I've followed the installation steps for Swift3 and Perfect2
and I've cloned the PerfectTemplate test project proposed by Perfect and I've tried 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
I've gone on different SO questions that seemed similar but all on different projects and attempted to try their solutions without luck:
For example:
Matlab Kalman /usr/bin/ld: cannot find -lstdc++
I also noticed the warning coming from the clang version, I am aware that my current version is 3.4, but that is what was installed via sudo apt-get install clang
as mentioned in the documentation.
I've also tried installing the 3.6 version of clang with: sudo apt-get install clang-3.n
However, after when I try swift build
again I get the following error:
error: invalid inferred toolchain: could not find
clang
How do I get rid of the /usr/bin/ld: cannot find -lstdc++
error, so I can build the PerfectTemplate project?
Try this. It might not work, but it's worth a shot.
Update packages and dependencies:
sudo apt-get update
Then install 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
I hope this helps, but apologies if it doesn't. Best of luck!
If this error appears:
/usr/bin/ld.gold: error: cannot open /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../../libstdc++.so: No such file or directory
It's most likely that the libstdc++.so
symbolic link points to an inexisting file.
In my case it was pointing to:
/usr/lib/libstdc++.so -> /usr/lib/libstdc++.so.6
Which was incorrect because libstdc++.so.6
did not exist in that area. Simply find it's location via: sudo find / -name libstdc++.so.6
which gave me:
/usr/lib/x86_64-linux-gnu/libstdc++.so.6
Then recreate the link with:
sudo rm /usr/lib/libstdc++.so
sudo ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /usr/lib/libstdc++.so