diff -Nru udunits-2.2.28.orig/lib/xml.c udunits-2.2.28/lib/xml.c
--- udunits-2.2.28.orig/lib/xml.c	2020-12-07 19:37:03.000000000 +0100
+++ udunits-2.2.28/lib/xml.c	2023-06-17 16:05:05.517340848 +0200
@@ -38,7 +38,7 @@
 #endif
 #include <sys/stat.h>
 #include <sys/types.h>
-#if defined(__linux__)
+#if defined(__linux__) || defined(__sun)
 #include <dlfcn.h>
 #elif defined(__APPLE__)
 #define _DARWIN_C_SOURCE
@@ -2137,7 +2137,7 @@
     if (absXmlPathname[0] == 0) {
         const char* prefix = NULL; // Installation directory
 
-#       if defined(__APPLE__) || defined(__linux__)
+#       if defined(__APPLE__) || defined(__linux__) || defined(__sun)
             Dl_info     info;
             const char  sep = '/'; // Pathname component separator
             char        buf[PATH_MAX];