Buliding llvm示例,/llvm/lib/Support/Mutex.cpp:53:未定义引用`pthread_mutexattr_init' [英] Buliding llvm examples, /llvm/lib/Support/Mutex.cpp:53: undefined reference to `pthread_mutexattr_init'

查看:2084
本文介绍了Buliding llvm示例,/llvm/lib/Support/Mutex.cpp:53:未定义引用`pthread_mutexattr_init'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试按照 http://llvm.org/docs/tutorial上的步骤操作/LangImpl3.html 构建示例。



基于



建筑llvm示例



#error在#include支持/ DataTypes.h之前必须#define __STDC_LIMIT_MACROS a>





我最后使用命令

  clang ++ -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -std = c ++ 11 -g -O3 toy.cpp`llvm-config --libs core --cppflags --ldflags` -o toy 

这是给予

  /usr/local/lib/libLLVMSupport.a(Mutex.o):在函数`llvm :: sys :: MutexImpl :: MutexImpl(bool)':
/ home / abdev / llvmHome / llvm / lib / Support / Mutex.cpp:53:未定义引用`pthread_mutexattr_init'
/home/abdev/llvmHome/llvm/lib/Support/Mutex.cpp:59:未定义引用`pthread_mutexattr_settype'
/ home / abdev / llvmHome / llvm / lib / Support / Mutex.cpp:67:undefined reference to`pthread_mutexattr_destroy'
/usr/local/lib/libLLVMSupport.a(Mutex.o):在函数`llvm :: sys :: MutexImpl :: tryacquire()':
/home/abdev/llvmHome/llvm/lib/Support/Mutex.cpp:109:未定义引用`pthread_mutex_trylock'
/ usr / local / lib /libLLVMSupport.a(RWMutex.o):在函数`llvm :: sys :: RWMutexImpl :: RWMutexImpl()':
/home/abdev/llvmHome/llvm/lib/Support/RWMutex.cpp:59:未定义的引用`pthread_rwlock_init'
/usr/local/lib/libLLVMSupport.a(RWMutex.o):在函数`llvm :: sys :: RWMutexImpl ::〜RWMutexImpl()':
/ home /abdev/llvmHome/llvm/lib/Support/RWMutex.cpp:72:未定义的引用`pthread_rwlock_destroy'
/usr/local/lib/libLLVMSupport.a(RWMutex.o):在函数`llvm :: sys :: RWMutexImpl :: reader_acquire()':
/home/abdev/llvmHome/llvm/lib/Support/RWMutex.cpp:82:未定义引用`pthread_rwlock_rdlock'
/ usr / local / lib / libLLVMSupport.a(RWMutex.o):在函数`llvm :: sys :: RWMutexImpl :: reader_release()':
/home/abdev/llvmHome/llvm/lib/Support/RWMutex.cpp:92:undefined引用`pthread_rwlock_unlock'
/usr/local/lib/libLLVMSupport.a(RWMutex.o):在函数`llvm :: sys :: RWMutexImpl :: writer_acquire()':
/ home / abdev /llvmHome/llvm/lib/Support/RWMutex.cpp:102:未定义的引用`pthread_rwlock_wrlock'
/usr/local/lib/libLLVMSupport.a(RWMutex.o):在函数`llvm :: sys :: RWMutexImpl :: writer_release()':
/home/abdev/llvmHome/llvm/lib/Support/RWMutex.cpp:112:未定义引用`pthread_rwlock_unlock'
/ usr / local / lib / libLLVMSupport。 a(Signals.o):在函数`llvm :: sys :: PrintStackTrace(_IO_FILE *)':
/home/abdev/llvmHome/llvm/lib/Support/Unix/Signals.inc:278:undefined reference到`dladdr'
/home/abdev/llvmHome/llvm/lib/Support/Unix/Signals.inc:290:未定义对`dladdr'的引用
/usr/local/lib/libLLVMSupport.a ThreadLocal.o):在函数`llvm :: sys :: ThreadLocalImpl :: ThreadLocalImpl()':
/home/abdev/llvmHome/llvm/lib/Support/ThreadLocal.cpp:56:未定义引用`pthread_key_create '
/usr/local/lib/libLLVMSupport.a(ThreadLocal.o):在函数`llvm :: sys :: ThreadLocalImpl ::〜ThreadLocalImpl()':
/ home / abdev / llvmHome / llvm / lib / Support / ThreadLocal.cpp:63:undefined reference to`pthread_key_delete'
/usr/local/lib/libLLVMSupport.a(ThreadLocal.o):在函数`llvm :: sys :: ThreadLocalImpl :: setInstance(void const *)':
/home/abdev/llvmHome/llvm/lib/Support/ThreadLocal.cpp:70:未定义引用`pthread_setspecific'
/ usr / local / lib / libLLVMSupport。 a(ThreadLocal.o):在函数`llvm :: sys :: ThreadLocalImpl :: getInstance()':
/home/abdev/llvmHome/llvm/lib/Support/ThreadLocal.cpp:77:undefined `pthread_getspecific'
/usr/local/lib/libLLVMSupport.a(Threading.o):在函数`llvm :: llvm_execute_on_thread(void(*)(void *),void *,unsigned int)':
/home/abdev/llvmHome/llvm/lib/Support/Threading.cpp:91:未定义引用`pthread_attr_setstacksize'
/home/abdev/llvmHome/llvm/lib/Support/Threading.cpp:96:未定义的引用`pthread_create'
/home/abdev/llvmHome/llvm/lib/Support/Threading.cpp:100:未定义引用`pthread_join'
clang:error:linker命令失败,退出代码为1 (使用-v查看调用)

我缺少一个库, ?

我相信你需要链接到-lpthread或者只是-pthread


I'm attempting to follow the steps on http://llvm.org/docs/tutorial/LangImpl3.html to build the example.

based on

Building llvm examples

#error "Must #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h"

Why am I getting "undefined reference to `dladdr'" even with -ldl for this simple program?

I've ended up with the command

clang++ -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -std=c++11 -g -O3 toy.cpp `llvm-config --libs core --cppflags --ldflags` -o toy

which is giving

/usr/local/lib/libLLVMSupport.a(Mutex.o): In function `llvm::sys::MutexImpl::MutexImpl(bool)':
/home/abdev/llvmHome/llvm/lib/Support/Mutex.cpp:53: undefined reference to `pthread_mutexattr_init'
/home/abdev/llvmHome/llvm/lib/Support/Mutex.cpp:59: undefined reference to `pthread_mutexattr_settype'
/home/abdev/llvmHome/llvm/lib/Support/Mutex.cpp:67: undefined reference to `pthread_mutexattr_destroy'
/usr/local/lib/libLLVMSupport.a(Mutex.o): In function `llvm::sys::MutexImpl::tryacquire()':
/home/abdev/llvmHome/llvm/lib/Support/Mutex.cpp:109: undefined reference to `pthread_mutex_trylock'
/usr/local/lib/libLLVMSupport.a(RWMutex.o): In function `llvm::sys::RWMutexImpl::RWMutexImpl()':
/home/abdev/llvmHome/llvm/lib/Support/RWMutex.cpp:59: undefined reference to `pthread_rwlock_init'
/usr/local/lib/libLLVMSupport.a(RWMutex.o): In function `llvm::sys::RWMutexImpl::~RWMutexImpl()':
/home/abdev/llvmHome/llvm/lib/Support/RWMutex.cpp:72: undefined reference to `pthread_rwlock_destroy'
/usr/local/lib/libLLVMSupport.a(RWMutex.o): In function `llvm::sys::RWMutexImpl::reader_acquire()':
/home/abdev/llvmHome/llvm/lib/Support/RWMutex.cpp:82: undefined reference to `pthread_rwlock_rdlock'
/usr/local/lib/libLLVMSupport.a(RWMutex.o): In function `llvm::sys::RWMutexImpl::reader_release()':
/home/abdev/llvmHome/llvm/lib/Support/RWMutex.cpp:92: undefined reference to `pthread_rwlock_unlock'
/usr/local/lib/libLLVMSupport.a(RWMutex.o): In function `llvm::sys::RWMutexImpl::writer_acquire()':
/home/abdev/llvmHome/llvm/lib/Support/RWMutex.cpp:102: undefined reference to `pthread_rwlock_wrlock'
/usr/local/lib/libLLVMSupport.a(RWMutex.o): In function `llvm::sys::RWMutexImpl::writer_release()':
/home/abdev/llvmHome/llvm/lib/Support/RWMutex.cpp:112: undefined reference to `pthread_rwlock_unlock'
/usr/local/lib/libLLVMSupport.a(Signals.o): In function `llvm::sys::PrintStackTrace(_IO_FILE*)':
/home/abdev/llvmHome/llvm/lib/Support/Unix/Signals.inc:278: undefined reference to `dladdr'
/home/abdev/llvmHome/llvm/lib/Support/Unix/Signals.inc:290: undefined reference to `dladdr'
/usr/local/lib/libLLVMSupport.a(ThreadLocal.o): In function `llvm::sys::ThreadLocalImpl::ThreadLocalImpl()':
/home/abdev/llvmHome/llvm/lib/Support/ThreadLocal.cpp:56: undefined reference to `pthread_key_create'
/usr/local/lib/libLLVMSupport.a(ThreadLocal.o): In function `llvm::sys::ThreadLocalImpl::~ThreadLocalImpl()':
/home/abdev/llvmHome/llvm/lib/Support/ThreadLocal.cpp:63: undefined reference to `pthread_key_delete'
/usr/local/lib/libLLVMSupport.a(ThreadLocal.o): In function `llvm::sys::ThreadLocalImpl::setInstance(void const*)':
/home/abdev/llvmHome/llvm/lib/Support/ThreadLocal.cpp:70: undefined reference to `pthread_setspecific'
/usr/local/lib/libLLVMSupport.a(ThreadLocal.o): In function `llvm::sys::ThreadLocalImpl::getInstance()':
/home/abdev/llvmHome/llvm/lib/Support/ThreadLocal.cpp:77: undefined reference to `pthread_getspecific'
/usr/local/lib/libLLVMSupport.a(Threading.o): In function `llvm::llvm_execute_on_thread(void (*)(void*), void*, unsigned int)':
/home/abdev/llvmHome/llvm/lib/Support/Threading.cpp:91: undefined reference to `pthread_attr_setstacksize'
/home/abdev/llvmHome/llvm/lib/Support/Threading.cpp:96: undefined reference to `pthread_create'
/home/abdev/llvmHome/llvm/lib/Support/Threading.cpp:100: undefined reference to `pthread_join'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Am I missing a library, or is some of the order incorrect?

解决方案

I believe you need to link with -lpthread or just -pthread

这篇关于Buliding llvm示例,/llvm/lib/Support/Mutex.cpp:53:未定义引用`pthread_mutexattr_init'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆