5

Description:

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

Error Message:

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

What I've tried:

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

Question:

How do I get rid of the /usr/bin/ld: cannot find -lstdc++ error, so I can build the PerfectTemplate project?

Community
  • 1
  • 1
kemicofa ghost
  • 16,349
  • 8
  • 82
  • 131

3 Answers3

11

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
kemicofa ghost
  • 16,349
  • 8
  • 82
  • 131
user3353890
  • 1,844
  • 1
  • 16
  • 31
  • Hmm this is pretty good. Thanks. I'm getting a new error "/usr/bin/ld.gold: error: cannot open /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../../libstdc++.so: No such file or directory" Any ideas? – kemicofa ghost Dec 01 '16 at 07:51
  • Try to cd into the directory it's giving in the error, and then apt-get install the missing file. I'm not sure as to the specifics of the error, but it's obvious you're missing something. So try cd-ing down and apt-get install libstdc++.so ....based off what you put above that would be my first guess as to what you're missing. – user3353890 Dec 01 '16 at 20:19
  • 1
    it would appear so. I'm not getting any errors when I swift build. I'll test the run later on this week and I'll let you know if any more problems show up. Thank you for the help ! – kemicofa ghost Dec 01 '16 at 22:54
  • You're welcome! I'm so glad you got it working. Great job! Feel free to reach out if there is anything else and I'll be glad to help if I can. – user3353890 Dec 01 '16 at 22:57
9
sudo apt-get install build-essential
saucym
  • 91
  • 1
  • 3
1

I faced with same problem and update-alternatives didn't help me, but after

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

swift build ran successfully. Looks like some dependencies were deprecated.