Cygwin中Clang的问题

时间:2015-06-26 21:02:39

标签: cygwin clang

我正在尝试在Cygwin中使用Clang。我尝试从Cygwin设置安装Clang。我写了一个简单的Hello世界!程序,但我收到了这些错误

/cygdrive/c/Users/John/.babun/cygwin/tmp/foo-0b3b5b.o:(.text+0x1a): undefined reference to `std::ios_base::Init::Init()'
/cygdrive/c/Users/John/.babun/cygwin/tmp/foo-0b3b5b.o:(.text+0x1a): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `std::ios_base::Init::Init()'
/cygdrive/c/Users/John/.babun/cygwin/tmp/foo-0b3b5b.o:(.text+0x20): undefined reference to `std::ios_base::Init::~Init()'
/cygdrive/c/Users/John/.babun/cygwin/tmp/foo-0b3b5b.o:(.text+0x66): undefined reference to `std::cout'
/cygdrive/c/Users/John/.babun/cygwin/tmp/foo-0b3b5b.o:(.text+0x79): 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*)'
/cygdrive/c/Users/John/.babun/cygwin/tmp/foo-0b3b5b.o:(.text+0x79): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
collect2: error: ld returned 1 exit status
clang: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)

使用以下代码创建文件clang++ foo.cpp后,我从终端运行foo.cpp

#include <iostream>

int main() {
    std::cout << "Hello world";
    return 0;
}

当我使用g ++时,它可以工作。为什么clang错误引用gcc?如何解决这个问题的任何帮助将不胜感激。

感谢。

0 个答案:

没有答案