Почему я получаю «неопределенную ссылку на« dladdr »» даже с -ldl для этой простой программы?

я работаю черезУчебник LLVM, но я'У меня проблемы с компиляцией. Я'Мы написали минимальный пример, который воспроизводит проблему:

#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;
}

Когда я пытаюсь скомпилировать, я получаю кучунеопределенные ссылки' erros:

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

Если я просматриваю man-страницу для dladdr, он говорит, что мне нужно связаться с-ldl, Но я'Я уже делаю это с:llvm-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

Дополнительно,-ldl отображается в правильном порядке (т. е. после.o файл, который требует символы) .I '

м в недоумении для следующего шага в отладке этой проблемы. Может кто-то указать мне верное направление? Я'м работает LVVM 2.9-7 на Ubuntu 12.04.

Ответы на вопрос(2)

Ваш ответ на вопрос