double-conversion icon indicating copy to clipboard operation
double-conversion copied to clipboard

Ubuntu 16.04: stdc++ not recognized

Open JeffreyBenjaminBrown opened this issue 8 years ago • 9 comments

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 avatar Nov 03 '17 06:11 JeffreyBenjaminBrown

@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.

hvr avatar Nov 03 '17 11:11 hvr

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.

JeffreyBenjaminBrown avatar Nov 03 '17 19:11 JeffreyBenjaminBrown

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;
}

hvr avatar Nov 03 '17 20:11 hvr

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 avatar Nov 03 '17 20:11 JeffreyBenjaminBrown

@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

hvr avatar Nov 03 '17 21:11 hvr

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 ..)

JeffreyBenjaminBrown avatar Nov 03 '17 21:11 JeffreyBenjaminBrown

I'm hitting the same issue on CentOS 6, did you find a solution?

janvogt avatar Mar 15 '18 11:03 janvogt

@janvogt Aside from using Cabal? I did not. But I didn't keep looking either; it might be out there.

JeffreyBenjaminBrown avatar Mar 15 '18 14:03 JeffreyBenjaminBrown

People using Ubuntu or any other Debian-based distro here there are two solutions that worked for me:

  1. Just install g++-7 before running stack build:
apt-get update && apt-get install g++-7 -y
  1. 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"

gvolpe avatar Jan 11 '19 15:01 gvolpe