# Purpose of patches removing "-ldl"



## tuaris (Aug 9, 2020)

I've come across this more than once and I don't understand the effect of ports include patches to remove any mentions of "-ldl" when building.

Random example: https://svnweb.freebsd.org/ports/he...h-configure.ac?revision=433881&view=markup#l8

Why is that?  The build seems to work with or without it. 

Should I be doing the same?


----------



## unitrunker (Aug 9, 2020)

The symbols are already exported from libc.


----------



## Jose (Aug 9, 2020)

Linking against `libdl` is harmless, but unnecessary.
dlopen(3)


> Other ELF platforms require linking with library "libdl" to provide
> *dlopen*() and other    functions.  FreeBSD does not require linking with the
> library, but supports it for compatibility.



Edit: Not always harmless. See below.


----------



## shkhln (Aug 9, 2020)

https://reviews.freebsd.org/D11504:


> After 20+ years, we must admit a defeat and agree that the external world wants -ldl to work. … This should reduce the need to patch out -ldl from naive builds, and reduce the need to fix errors regarding detection of -ldl from less naive.


----------

