diff --git a/src/video/x11/SDL_x11gl.c b/src/video/x11/SDL_x11gl.c
index 43334c10f28effbdbf7fda2833afe6ec6a901e4f..1d767e17f0d849359de2c7ac073bfe2dcf584ef1 100644
--- a/src/video/x11/SDL_x11gl.c
+++ b/src/video/x11/SDL_x11gl.c
@@ -479,7 +479,11 @@ int X11_GL_LoadLibrary(_THIS, const char* path)
 
 	handle = GL_LoadObject(path);
 	if ( handle == NULL ) {
+#if defined(OPENGL_REQUIRS_DLOPEN) && defined(SDL_LOADSO_DLOPEN)
+		SDL_SetError("Failed loading %s", path);
+#else
 		/* SDL_LoadObject() will call SDL_SetError() for us. */
+#endif
 		return -1;
 	}