diff --git a/src/core/linux/SDL_udev.c b/src/core/linux/SDL_udev.c
index 502490b70..37bc4224f 100644
--- a/src/core/linux/SDL_udev.c
+++ b/src/core/linux/SDL_udev.c
@@ -36,14 +36,7 @@
 #include "SDL_timer.h"
 #include "../unix/SDL_poll.h"
 
-static const char *SDL_UDEV_LIBS[] = {
-#ifdef SDL_UDEV_DYNAMIC
-	SDL_UDEV_DYNAMIC
-#else
-	"libudev.so.1",
-	"libudev.so.0"
-#endif
-};
+static const char *SDL_UDEV_LIBS[] = { "libudev.so.1", "libudev.so.0" };
 
 #define _THIS SDL_UDEV_PrivateData *_this
 static _THIS = NULL;
@@ -261,6 +254,19 @@ SDL_UDEV_LoadLibrary(void)
         return 0;
     }
 
+#ifdef SDL_UDEV_DYNAMIC
+    /* Check for the build environment's libudev first */
+    if (_this->udev_handle == NULL) {
+        _this->udev_handle = SDL_LoadObject(SDL_UDEV_DYNAMIC);
+        if (_this->udev_handle != NULL) {
+            retval = SDL_UDEV_load_syms();
+            if (retval < 0) {
+                SDL_UDEV_UnloadLibrary();
+            }
+        }
+    }
+#endif
+
     if (_this->udev_handle == NULL) {
         for( i = 0 ; i < SDL_arraysize(SDL_UDEV_LIBS); i++) {
             _this->udev_handle = SDL_LoadObject(SDL_UDEV_LIBS[i]);