[PATCH] Link with -ldl on GNU/kFreeBSD

Peter Colberg peter at colberg.org
Sat Jul 2 03:33:17 CEST 2016


On Fri, Jul 01, 2016 at 11:56:55PM +0200, Jason A. Donenfeld wrote:
> I wonder if a better way would be match the particular libc out of
> uname -o. In this case, GNU libc needs -ldl. Do other libcs also need
> libdl? Seems like this might be slightly cleaner.

In theory one could detect glibc by grepping for specific macros,

cc -E -dM -include dlfcn.h -xc /dev/null

but in practice other libcs pretend being glibc:

https://git.uclibc.org/uClibc/tree/include/features.h

/*  There is an unwholesomely huge amount of code out there that depends on the
 *  presence of GNU libc header files.  We have GNU libc header files.  So here
 *  we commit a horrible sin.  At this point, we _lie_ and claim to be GNU libc

Peter


More information about the CGit mailing list