¿Por qué recibo "una referencia indefinida a` dladdr '”incluso con -ldl para este programa simple?

Estoy trabajando a través de unTutorial LLVM, pero estoy teniendo problemas para compilar. He escrito un ejemplo mínimo que reproduce el problema:

#include "llvm/Module.h"
#include "llvm/LLVMContext.h"

int main(int argc, char **argv) {
    llvm::Module *module = new llvm::Module("test", llvm::getGlobalContext());
    return 0;
}

Cuando intento compilar, obtengo un montón de errores de 'referencia no definida':

clang++ `llvm-config --cxxflags`   -c -o test.o test.cpp
clang++  test.o  `llvm-config --ldflags --libs core` -o test
/usr/lib/llvm-2.9/lib/libLLVMSupport.a(Signals.o): In function `PrintStackTrace(void*)':
(.text+0x6c): undefined reference to `dladdr'
/usr/lib/llvm-2.9/lib/libLLVMSupport.a(Signals.o): In function `PrintStackTrace(void*)':
(.text+0x1f6): undefined reference to `dladdr'
/usr/lib/llvm-2.9/lib/libLLVMSupport.a(Mutex.o): In function `llvm::sys::MutexImpl::MutexImpl(bool)':
(.text+0x53): undefined reference to `pthread_mutexattr_init'
/usr/lib/llvm-2.9/lib/libLLVMSupport.a(Mutex.o): In function `llvm::sys::MutexImpl::MutexImpl(bool)':
(.text+0x64): undefined reference to `pthread_mutexattr_settype'
/usr/lib/llvm-2.9/lib/libLLVMSupport.a(Mutex.o): In function `llvm::sys::MutexImpl::MutexImpl(bool)':
(.text+0x74): undefined reference to `pthread_mutexattr_setpshared'
/usr/lib/llvm-2.9/lib/libLLVMSupport.a(Mutex.o): In function `llvm::sys::MutexImpl::MutexImpl(bool)':
(.text+0x88): undefined reference to `pthread_mutexattr_destroy'
/usr/lib/llvm-2.9/lib/libLLVMSupport.a(Mutex.o): In function `llvm::sys::MutexImpl::tryacquire()':
(.text+0x179): undefined reference to `pthread_mutex_trylock'
/usr/lib/llvm-2.9/lib/libLLVMSupport.a(RWMutex.o): In function `llvm::sys::RWMutexImpl::RWMutexImpl()':
(.text+0x3e): undefined reference to `pthread_rwlock_init'
/usr/lib/llvm-2.9/lib/libLLVMSupport.a(RWMutex.o): In function `llvm::sys::RWMutexImpl::~RWMutexImpl()':
(.text+0x80): undefined reference to `pthread_rwlock_destroy'
/usr/lib/llvm-2.9/lib/libLLVMSupport.a(RWMutex.o): In function `llvm::sys::RWMutexImpl::reader_acquire()':
(.text+0xb9): undefined reference to `pthread_rwlock_rdlock'
/usr/lib/llvm-2.9/lib/libLLVMSupport.a(RWMutex.o): In function `llvm::sys::RWMutexImpl::reader_release()':
(.text+0xe9): undefined reference to `pthread_rwlock_unlock'
/usr/lib/llvm-2.9/lib/libLLVMSupport.a(RWMutex.o): In function `llvm::sys::RWMutexImpl::writer_acquire()':
(.text+0x119): undefined reference to `pthread_rwlock_wrlock'
/usr/lib/llvm-2.9/lib/libLLVMSupport.a(RWMutex.o): In function `llvm::sys::RWMutexImpl::writer_release()':
(.text+0x149): undefined reference to `pthread_rwlock_unlock'
/usr/lib/llvm-2.9/lib/libLLVMSupport.a(Threading.o): In function `llvm::llvm_execute_on_thread(void (*)(void*), void*, unsigned int)':
(.text+0x1cc): undefined reference to `pthread_create'
/usr/lib/llvm-2.9/lib/libLLVMSupport.a(Threading.o): In function `llvm::llvm_execute_on_thread(void (*)(void*), void*, unsigned int)':
(.text+0x208): undefined reference to `pthread_attr_setstacksize'
/usr/lib/llvm-2.9/lib/libLLVMSupport.a(Threading.o): In function `llvm::llvm_execute_on_thread(void (*)(void*), void*, unsigned int)':
(.text+0x228): undefined reference to `pthread_join'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [test] Error 1

Si veo la página de manual de dladdr, dice que necesito enlazar con-ldl. Pero ya estoy haciendo eso conllvm-config:

$ llvm-config --ldflags --libs core
-L/usr/lib/llvm-2.9/lib  -lpthread -lffi -ldl -lm 
-lLLVMCore -lLLVMSupport -L/usr/lib/llvm-2.9/lib

Adicionalmente,-ldl aparece en el orden correcto (es decir, después de la.o archivo que requiere los símbolos).

Estoy en una pérdida para el siguiente paso en la depuración de este problema. ¿Alguien puede señalarme en la dirección correcta? Estoy ejecutando LVVM 2.9-7 en Ubuntu 12.04.

Respuestas a la pregunta(2)

Su respuesta a la pregunta