Fix build error caused by pthread lib order

https://github.com/BVLC/caffe/issues/1327