--- lib/thread_mosq.c
+++ lib/thread_mosq.c
@@ -42,7 +42,9 @@
 	mosq->threaded = mosq_ts_self;
 	if(!pthread_create(&mosq->thread_id, NULL, mosquitto__thread_main, mosq)){
 #if defined(__linux__)
+#if ((__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 12)))
 		pthread_setname_np(mosq->thread_id, "mosquitto loop");
+#endif
 #elif defined(__NetBSD__)
 		pthread_setname_np(mosq->thread_id, "%s", "mosquitto loop");
 #elif defined(__FreeBSD__) || defined(__OpenBSD__)
