[CentOS] How to compile APUE code on centos 6.X

Tue Jul 29 14:00:53 UTC 2014
Theodore Si <sjyzhxw at gmail.com>

Hi all,

I want to compile the source code of Advanced Programming in the Unix
Environment(APUE) 3rd edition, and I encountered some difficulties.
After executing "make", I got this message:

gcc -ansi -I../include -Wall -DLINUX -D_GNU_SOURCE barrier.c -o barrier
-L../lib -lapue -pthread -lrt -lbsd
/tmp/cc0gG99O.o: In function `thr_fn':
barrier.c:(.text+0x6e): undefined reference to `heapsort'
collect2: ld returned 1 exit status
make[1]: *** [barrier] Error 1
make[1]: Leaving directory `/home/drizzlex/apue.3e/threads'
make: *** [all] Error 1


In barrier.c, I found this

#ifdef SOLARIS
#define heapsort qsort
#else
extern int heapsort(void *, size_t, size_t,
int (*)(const void *, const void *));
#endif

If I change these code to

How to install libbsd to solve this problem on CentOS (this works on
Ubuntu)?