0

我正在尝试编译一个简单的“hello world”测试程序,如下所示为“hello.cpp”。

你好.cpp:

#include <iostream>

int main(int argc, char** argv) {
    std::cout << "Hello world!\n";
    return 0;
}

要编译,我正在使用

$ clang --version
clang version 3.2 (tags/RELEASE_32/final 191651)
Target: x86_64-unknown-linux-gnu
Thread model: posix

在 RHEL5 操作系统上,通过完全按照这些步骤安装 clang 。

但是当我尝试编译时,我得到了大量我不明白的错误:

$ clang hello.cpp -o hello
In file included from hello.cpp:1:
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/iostream:43:
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/ostream:43:
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/ios:42:
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/iosfwd:45:
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/c++io.h:38:
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr.h:132:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:100:1: error: weakref declaration must have
      internal linkage
__gthrw(pthread_once)
^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:81:23: note: expanded from macro '__gthrw'
#define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
                      ^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:72:46: note: expanded from macro '__gthrw2'
  extern __typeof(type) name __attribute__ ((__weakref__(#name2))); \
                                             ^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:101:1: error: weakref declaration must have
      internal linkage
__gthrw(pthread_getspecific)
^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:81:23: note: expanded from macro '__gthrw'
#define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
                      ^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:72:46: note: expanded from macro '__gthrw2'
  extern __typeof(type) name __attribute__ ((__weakref__(#name2))); \
                                             ^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:102:1: error: weakref declaration must have
      internal linkage
__gthrw(pthread_setspecific)
^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:81:23: note: expanded from macro '__gthrw'
#define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
                      ^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:72:46: note: expanded from macro '__gthrw2'
  extern __typeof(type) name __attribute__ ((__weakref__(#name2))); \
                                             ^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:103:1: error: weakref declaration must have
      internal linkage
__gthrw(pthread_create)
^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:81:23: note: expanded from macro '__gthrw'
#define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
                      ^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:72:46: note: expanded from macro '__gthrw2'
  extern __typeof(type) name __attribute__ ((__weakref__(#name2))); \
                                             ^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:104:1: error: weakref declaration must have
      internal linkage
__gthrw(pthread_cancel)
^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:81:23: note: expanded from macro '__gthrw'
#define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
                      ^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:72:46: note: expanded from macro '__gthrw2'
  extern __typeof(type) name __attribute__ ((__weakref__(#name2))); \
                                             ^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:105:1: error: weakref declaration must have
      internal linkage
__gthrw(pthread_mutex_lock)
^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:81:23: note: expanded from macro '__gthrw'
#define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
                      ^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:72:46: note: expanded from macro '__gthrw2'
  extern __typeof(type) name __attribute__ ((__weakref__(#name2))); \
                                             ^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:106:1: error: weakref declaration must have
      internal linkage
__gthrw(pthread_mutex_trylock)
^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:81:23: note: expanded from macro '__gthrw'
#define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
                      ^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:72:46: note: expanded from macro '__gthrw2'
  extern __typeof(type) name __attribute__ ((__weakref__(#name2))); \
                                             ^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:107:1: error: weakref declaration must have
      internal linkage
__gthrw(pthread_mutex_unlock)
^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:81:23: note: expanded from macro '__gthrw'
#define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
                      ^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:72:46: note: expanded from macro '__gthrw2'
  extern __typeof(type) name __attribute__ ((__weakref__(#name2))); \
                                             ^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:108:1: error: weakref declaration must have
      internal linkage
__gthrw(pthread_mutex_init)
^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:81:23: note: expanded from macro '__gthrw'
#define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
                      ^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:72:46: note: expanded from macro '__gthrw2'
  extern __typeof(type) name __attribute__ ((__weakref__(#name2))); \
                                             ^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:109:1: error: weakref declaration must have
      internal linkage
__gthrw(pthread_cond_broadcast)
^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:81:23: note: expanded from macro '__gthrw'
#define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
                      ^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:72:46: note: expanded from macro '__gthrw2'
  extern __typeof(type) name __attribute__ ((__weakref__(#name2))); \
                                             ^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:110:1: error: weakref declaration must have
      internal linkage
__gthrw(pthread_cond_wait)
^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:81:23: note: expanded from macro '__gthrw'
#define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
                      ^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:72:46: note: expanded from macro '__gthrw2'
  extern __typeof(type) name __attribute__ ((__weakref__(#name2))); \
                                             ^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:113:1: error: weakref declaration must have
      internal linkage
__gthrw(pthread_key_create)
^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:81:23: note: expanded from macro '__gthrw'
#define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
                      ^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:72:46: note: expanded from macro '__gthrw2'
  extern __typeof(type) name __attribute__ ((__weakref__(#name2))); \
                                             ^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:114:1: error: weakref declaration must have
      internal linkage
__gthrw(pthread_key_delete)
^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:81:23: note: expanded from macro '__gthrw'
#define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
                      ^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:72:46: note: expanded from macro '__gthrw2'
  extern __typeof(type) name __attribute__ ((__weakref__(#name2))); \
                                             ^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:115:1: error: weakref declaration must have
      internal linkage
__gthrw(pthread_mutexattr_init)
^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:81:23: note: expanded from macro '__gthrw'
#define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
                      ^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:72:46: note: expanded from macro '__gthrw2'
  extern __typeof(type) name __attribute__ ((__weakref__(#name2))); \
                                             ^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:116:1: error: weakref declaration must have
      internal linkage
__gthrw(pthread_mutexattr_settype)
^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:81:23: note: expanded from macro '__gthrw'
#define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
                      ^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:72:46: note: expanded from macro '__gthrw2'
  extern __typeof(type) name __attribute__ ((__weakref__(#name2))); \
                                             ^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:117:1: error: weakref declaration must have
      internal linkage
__gthrw(pthread_mutexattr_destroy)
^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:81:23: note: expanded from macro '__gthrw'
#define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
                      ^
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:72:46: note: expanded from macro '__gthrw2'
  extern __typeof(type) name __attribute__ ((__weakref__(#name2))); \
                                             ^
16 errors generated. 

我还需要做些什么才能让 clang 在我的系统上工作吗?还是我的源代码安装完全搞砸了?

4

0 回答 0