O Clang ++ não pode encontrar o lstdc ++ após a atualização do sistema

2

Eu tenho um pequeno projeto em C ++ que compilou bem até que eu atualizei o Xubuntu para o 15.04. Quando tentei reconstruí-lo com o cmake, esta mensagem apareceu no meio da saída:

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

Então, tentei escrever um programa simples para ver se cmake era responsável por ele:

int main() {
    return 0;
}

Coisa engraçada: g++ compiles:

$ g++ main.cpp
$ ls
a.out  main.cpp
$ ./a.out
$

mas quando tento usar clang++ ...

$ clang++ main.cpp 
/usr/bin/ld: cannot find -lstdc++
clang: error: linker command failed with exit code 1 (use -v to see invocation)
$

Experimente com clang++ main.cpp -lc++ (como sugerido aqui ) ou com o sinal -static ( aqui ) apresenta exatamente o mesmo erro. Rodando com -v como sugerido por clang , eu entendi:

$ clang++ main.cpp -v
Ubuntu clang version 3.6.0-2ubuntu1 (tags/RELEASE_360/final) (based on LLVM 3.6.0)
Target: x86_64-pc-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/4.9
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/4.9.2
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/5.0.1
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.7
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.7.4
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9.2
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5.0.1
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9.2
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.0.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.2
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.0.1
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5.0.1
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
 "/usr/lib/llvm-3.6/bin/clang" -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name main.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -target-linker-version 2.25 -v -dwarf-column-info -resource-dir /usr/lib/llvm-3.6/bin/../lib/clang/3.6.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/5.0.1/../../../../include/c++ -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/5.0.1/../../../../include/c++/x86_64-linux-gnu -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/5.0.1/../../../../include/c++/backward -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-3.6/bin/../lib/clang/3.6.0/include -internal-externc-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/5.0.1/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -fdebug-compilation-dir /home/ryu/Dropbox/Aperture/working/C/learn-sdl/src -ferror-limit 19 -fmessage-length 100 -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/main-efcd57.o -x c++ main.cpp
clang -cc1 version 3.6.0 based upon LLVM 3.6.0 default target x86_64-pc-linux-gnu
ignoring nonexistent directory "/usr/bin/../lib/gcc/x86_64-linux-gnu/5.0.1/../../../../include/c++/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/bin/../lib/gcc/x86_64-linux-gnu/5.0.1/../../../../include/c++/backward"
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/bin/../lib/gcc/x86_64-linux-gnu/5.0.1/../../../../include/c++
 /usr/local/include
 /usr/lib/llvm-3.6/bin/../lib/clang/3.6.0/include
 /usr/bin/../lib/gcc/x86_64-linux-gnu/5.0.1/include
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
 "/usr/bin/ld" --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out /usr/bin/../lib/gcc/x86_64-linux-gnu/5.0.1/../../../x86_64-linux-gnu/crt1.o /usr/bin/../lib/gcc/x86_64-linux-gnu/5.0.1/../../../x86_64-linux-gnu/crti.o /usr/bin/../lib/gcc/x86_64-linux-gnu/5.0.1/crtbegin.o -L/usr/bin/../lib/gcc/x86_64-linux-gnu/5.0.1 -L/usr/bin/../lib/gcc/x86_64-linux-gnu/5.0.1/../../../x86_64-linux-gnu -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/bin/../lib/gcc/x86_64-linux-gnu/5.0.1/../../.. -L/usr/lib/llvm-3.6/bin/../lib -L/lib -L/usr/lib /tmp/main-efcd57.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/bin/../lib/gcc/x86_64-linux-gnu/5.0.1/crtend.o /usr/bin/../lib/gcc/x86_64-linux-gnu/5.0.1/../../../x86_64-linux-gnu/crtn.o
/usr/bin/ld: cannot find -lstdc++
clang: error: linker command failed with exit code 1 (use -v to see invocation)
$

Na qual não encontrei a fonte do erro.

Eu tentei remover e reinstalar build-essential , clang e g++ , mas não tive sorte. Eu também pesquisei, mas só encontrei este link de 2013 (sim, eu notei que isso é para a Red Hat ).

Então, minhas perguntas são:

  1. Como corrijo isso? ( Aparentemente, reinstalar pela terceira / quarta vez corrigiu isso. )

  2. Por que isso aconteceu em primeiro lugar, já que a única coisa que fiz foi atualizar o sistema?

por Ryu 06.08.2015 / 16:43

2 respostas

1

É muito estranho, mas remover gcc-go packet me ajudou.

    
por vladon 02.03.2016 / 20:44
0

Verifique se você vinculou o stdc ++ corretamente. Por exemplo. tente construir pelo g ++ e use o ldd para verificar onde está a biblioteca. Em seguida, verifique se existe uma hierarquia de links completa, por exemplo, (para stdc ++):

lrwxrwxrwx 1 root root   40 cze 14 12:34 /usr/lib/x86_64-linux-gnu/libstdc++.so -> libstdc++.so.6
lrwxrwxrwx 1 root root   19 maj 11 02:36 /usr/lib/x86_64-linux-gnu/libstdc++.so.6 -> libstdc++.so.6.0.22
-rw-r--r-- 1 root root 1,6M maj 11 03:05 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.22

No Ubuntu, por vezes, está faltando (provavelmente você não tem isso primeiro).

    
por Pajączek 14.06.2016 / 13:01