undefined reference to `pthread_create`的解决方法

编译的时候突然报这些错误:

libaeron_driver.so: undefined reference to `pthread_getspecific'
libaeron_driver.so: undefined reference to `pthread_key_create'
libaeron_driver.so: undefined reference to `pthread_once'
libaeron_driver.so: undefined reference to `pthread_setspecific'
libaeron_driver.so: undefined reference to `pthread_setname_np'
libaeron_driver.so: undefined reference to `pthread_join'
libaeron_driver.so: undefined reference to `pthread_create'

全是与线程有关的。

所以咯,最终发现是线程库没有链接,在编译选项中添加"-lpthread" ,编译通过。

至于undefined reference to错误,还有其他好多原因,这里就只讨论这一种哦。

你可能感兴趣的:(C++)