New comment by Johnnynator on void-packages repository https://github.com/void-linux/void-packages/issues/24959#issuecomment-695106184 Comment: > How could you be getting an undefined reference to -ldl if it's dynamically linked? You can obviously get undefined references if you don't link against libdl, you only need to link against it, if you want to use any of the symbols it provides. If you use `dlopen` or `dlclose` you should link against `${CMAKE_DL_LIBS}` https://cmake.org/cmake/help/latest/variable/CMAKE_DL_LIBS.html