为什么链接器找不到std :: cout和其他std条目?

时间:2014-02-02 03:18:50

标签: eclipse-cdt fedora clang++

我正在尝试使用Fedora下的Eclipse CDT Kepler下的clang ++编译一个简单的程序。下面是在Eclipse中运行的clang ++编译日志。

如果我在命令提示符下输入'clang ++ ../ src / Hello \ LLVM \ and \ Clang.cc',我没有错误。如果我输入Eclipse命令,我会复制链接错误消息。

各种SO和clang邮件列表表示对std :: ???的未定义引用是使用clang而不是clang ++以及使用libc ++而不是libstdc ++引起的。在第3行和第4行,使用了clang ++。在第4行,stdc ++。

我正在使用LLVM和Clang(Linux)Eclipse定义的工具链。 有趣的行为是当我选择Properties-> C / C ++ Build->工具链编辑器时,我看到LLVM与Clang(Linux)作为工具链。如果我选择Linux GCC。当我从工具链列表中选择时,带有Clang(Linux)的LLMV消失了!似乎该工具不受“支持”,但它似乎得到了支持。好奇。

如何在Eclipse CDT Kepler下构建clang ++?图书馆的路径似乎是问题的关键。

21:43:42 **** Rebuild of configuration Debug for project Hello LLVM and Clang ****
Info: Internal Builder is used for build
clang++ -O0 -emit-llvm -g3 -Wall -c -fmessage-length=0 -o "src/Hello LLVM and Clang.bc" "../src/Hello LLVM and Clang.cc" 
clang++ -v -L/usr/lib -L/usr/i686-w64-mingw32/sys-root/mingw/lib/ -o "Hello LLVM and Clang" "src/Hello LLVM and Clang.bc" -lstdc++ 
clang version 3.3 (tags/RELEASE_33/final)
Target: i386-redhat-linux-gnu
Thread model: posix
"/usr/bin/clang" -cc1 -triple i386-redhat-linux-gnu -emit-obj -mrelax-all -disable-free -  disable-llvm-verifier -main-file-name "Hello LLVM and Clang.bc" -mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -fuse-init-array -target-cpu pentium4 -target-linker-version 2.23.2 -v -resource-dir /usr/bin/../lib/clang/3.3 -fdebug-compilation-dir "/home/ksmith/C++PlayProjects/Hello LLVM and Clang/Debug" -ferror-limit 19 -fmessage-length 0 -mstackrealign -fobjc-runtime=gcc -fobjc-default-synthesize-properties -fdiagnostics-show-option -backend-option -vectorize-loops -o "/tmp/Hello LLVM and Clang-mT5CWp.o" -x ir "src/Hello LLVM and Clang.bc"
clang -cc1 version 3.3 based upon LLVM 3.3 default target i386-redhat-linux-gnu
"/usr/bin/ld" --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o "Hello LLVM and Clang" /usr/lib/gcc/i686-redhat-linux/4.8.2/../../../crt1.o /usr/lib/gcc/i686-redhat-linux/4.8.2/../../../crti.o /usr/lib/gcc/i686-redhat-linux/4.8.2/crtbegin.o -L/usr/lib -L/usr/i686-w64-mingw32/sys-root/mingw/lib/ -L/usr/lib/gcc/i686-redhat-linux/4.8.2 -L/usr/lib/gcc/i686-redhat-linux/4.8.2/../../.. -L/lib -L/usr/lib "/tmp/Hello LLVM and Clang-mT5CWp.o" -lstdc++ -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/i686-redhat-linux/4.8.2/crtend.o /usr/lib/gcc/i686-redhat-linux/4.8.2/../../../crtn.o
/tmp/Hello LLVM and Clang-mT5CWp.o: In function `main':
/home/ksmith/C++PlayProjects/Hello LLVM and Clang/Debug/../src/Hello LLVM and Clang.cc:12: undefined reference to `std::cout'
/home/ksmith/C++PlayProjects/Hello LLVM and Clang/Debug/../src/Hello LLVM and Clang.cc:13: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/home/ksmith/C++PlayProjects/Hello LLVM and Clang/Debug/../src/Hello LLVM and Clang.cc:13: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
/home/ksmith/C++PlayProjects/Hello LLVM and Clang/Debug/../src/Hello LLVM and Clang.cc:13: undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
/tmp/Hello LLVM and Clang-mT5CWp.o: In function `__cxx_global_var_init':
    /usr/lib/gcc/i686-redhat-linux/4.8.2/../../../../include/c++/4.8.2/iostream:74:     undefined reference to `std::ios_base::Init::Init()'
    /usr/lib/gcc/i686-redhat-linux/4.8.2/../../../../include/c++/4.8.2/iostream:74: undefined reference to `std::ios_base::Init::~Init()'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

21:43:44 Build Finished (took 1s.982ms)

0 个答案:

没有答案