Ubuntu 16.04: stdc++ not recognized
When I run apt-get install libstdc++6, I am informed that libstdc++6 is already the newest version (7.2.0-1ubuntu1~16.04).
But when I try to install double-conversion (using Stack), I get this error:
Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2: Missing dependency on a foreign
library:
* Missing C library: stdc++
@JeffreyBenjaminBrown the libstdc++6 package only provides the bare library, without the files needed for compile-time linkage;
I'd suggest to apt install g++ as that will iirc result in a minimal C++ devel environment of necessary -dev packages for C++ usage being installed, including the libstdc++-5-dev package, which is the one missing specifically.
Thank you, Mr. Riedel!
My system claims to already have the latest versions of both of those:
jeff@jbb-lenovo:~$ sudo apt install g++
[sudo] password for jeff:
Reading package lists... Done
Building dependency tree
Reading state information... Done
g++ is already the newest version (4:5.3.1-1ubuntu1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
jeff@jbb-lenovo:~$ sudo apt install libstdc++-5-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
libstdc++-5-dev is already the newest version (5.4.1-2ubuntu1~16.04).
libstdc++-5-dev set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
That's strange; can you create a file hello.cc somewhere with the content below, and then compile&link that via g++ hello.cc -o hello and see if that results in an executable hello?
#include <iostream>
int main(int argc, char *argv[])
{
std::cout << "Hello" << std::endl;
return 0;
}
Yessir! It seems to work:
jeff@jbb-lenovo:~/code/test-for-double-conversion$ cat hello.cc
#include <iostream>
int main(int argc, char *argv[])
{
std::cout << "Hello" << std::endl;
return 0;
}
jeff@jbb-lenovo:~/code/test-for-double-conversion$ g++ hello.cc -o hello
jeff@jbb-lenovo:~/code/test-for-double-conversion$ ./hello
Hello
jeff@jbb-lenovo:~/code/test-for-double-conversion$
@JeffreyBenjaminBrown can I ask you try to use Cabal to install double-conversion to see if that would have worked? You can either use Ubuntu's GHC by installing via apt install ghc cabal-install (or by using my Ubuntu PPA (see https://launchpad.net/~hvr/+archive/ubuntu/ghc) if you need a newer GHC than GHC 7.10.3);
and then just try cabal install double-conversion
Installing via cabal worked! My global Haskell installation uses GHC 7.10.3. (Alas, the code I hope to use it with is in Stack ..)
I'm hitting the same issue on CentOS 6, did you find a solution?
@janvogt Aside from using Cabal? I did not. But I didn't keep looking either; it might be out there.
People using Ubuntu or any other Debian-based distro here there are two solutions that worked for me:
- Just install
g++-7before runningstack build:
apt-get update && apt-get install g++-7 -y
- It's a bit longer but it's the first workaround I found and involves the creation of symbolic links:
ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /usr/lib/libstdc++.so
ln -s /usr/bin/g++-5 /usr/bin/g++
export PATH="/usr/lib/gcc/x86_64-linux-gnu/5:$PATH"