编译报错 undefined reference to `pthread_create'等

编译文件时,遇到错误如下:

XX undefined reference to `dlerror'
XX undefined reference to `pthread_create'
XX undefined reference to `floor'
XX undefined reference to `dladdr'
XX undefined reference to `dlclose'
XX undefined reference to `dlopen'
XX undefined reference to `dlsym'
collect2: error: ld returned 1 exit status

解决方法:

编译时链接库即可,在编译命令后添加:

-lpthread -ldl -lm

 

你可能感兴趣的:(linux)