我似乎无法让这个工作。我使用了--with-gcc-toolchain=
参数,并在等号后面放置了gcc所在的目录(/usr/lib/gcc-snapshot/bin
)。
我还查阅了“clang linker problem” 的答案,但我不知道如何获取接受的答案来找到正确的位置,而符号链接的答案本来可以起作用,但它正在搜索的所有目录都存在(将lib
文件夹从gcc快照复制到其中一个包含位置似乎也没有帮助)。
如其他问题建议的,将clang++ test.cpp -v
的输出:
bob@bob:~/programming$ clang++ test.cpp -v
clang version 3.3 (trunk 171350)
Target: x86_64-unknown-linux-gnu
Thread model: posix
"/home/bob/programming/build/Release+Asserts/bin/clang" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name test.cpp -mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-linker-version 2.22 -momit-leaf-frame-pointer -v -resource-dir /home/bob/programming/build/Release+Asserts/bin/../lib/clang/3.3 -fmodule-cache-path /var/tmp/clang-module-cache -internal-isystem /usr/local/include -internal-isystem /home/bob/programming/build/Release+Asserts/bin/../lib/clang/3.3/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/bob/programming -ferror-limit 19 -fmessage-length 80 -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -backend-option -vectorize-loops -o /tmp/test-PWiB4M.o -x c++ test.cpp
clang -cc1 version 3.3 based upon LLVM 3.3svn default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/home/bob/programming/build/Release+Asserts/bin/../lib/clang/3.3/include
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
test.cpp:1:10: fatal error: 'iostream' file not found
#include ^
1 error generated.
clang版本3.3(主干版本171350)
编辑:在构建中,Release+Asserts
文件夹中没有.o
文件。这正常吗?如果不是,请问原因是什么,如何解决(如果可以将其指向clang的stdlib,则可以解决)。
编辑2:它还无法编译int main(){return 0;}
,因为它找不到crtbegin.o
。完整输出如下:
/usr/bin/ld: 找不到crtbegin.o:没有那个文件或目录
/usr/bin/ld: 找不到-lgcc
/usr/bin/ld: 找不到-lgcc_s
clang: 错误:链接器命令失败,退出代码为1(使用-v查看调用)
使用-v
后的结果与上述相同,但结束错误不同。
Config.log:
完整文件可以在此处找到,但第一行(非注释)是:$ ../llvm/configure --with-gcc-toolchain=/usr/lib/gcc-snapshot/gcc