Я пытаюсь скомпилировать простую тестовую программу «hello world», которая показана ниже как «hello.cpp».
hello.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 работал в моей системе? Или моя сборка из исходного кода полностью испорчена?
Задача ещё не решена.
Других решений пока нет …