diff --git a/src/core/surface_factory_qt.cpp b/src/core/surface_factory_qt.cpp
index 85b9eb799ab3a4c236661d9ccdfcf93b75c0c41d..23fafb3c9c2521cacc756add229efcb5077d4e0a 100644
--- a/src/core/surface_factory_qt.cpp
+++ b/src/core/surface_factory_qt.cpp
@@ -55,6 +55,16 @@
 #define QT_LIBDIR_GLES2 QT_LIBDIR_EGL
 #endif
 
+base::NativeLibrary LoadLibrary(const base::FilePath& filename) {
+    base::NativeLibraryLoadError error;
+    base::NativeLibrary library = base::LoadNativeLibrary(filename, &error);
+    if (!library) {
+        LOG(ERROR) << "Failed to load " << filename.MaybeAsASCII() << ": " << error.ToString();
+        return NULL;
+    }
+    return library;
+}
+
 bool SurfaceFactoryQt::LoadEGLGLES2Bindings(AddGLLibraryCallback add_gl_library, SetGLGetProcAddressProcCallback set_gl_get_proc_address)
 {
 #if defined(OS_ANDROID)
@@ -65,19 +75,15 @@ bool SurfaceFactoryQt::LoadEGLGLES2Bindings(AddGLLibraryCallback add_gl_library,
 #else
     base::FilePath libEGLPath = toFilePath(QT_LIBDIR_EGL);
     libEGLPath = libEGLPath.Append("libEGL.so");
-    base::NativeLibrary eglLibrary = gfx::LoadLibrary(libEGLPath);
-    if (!eglLibrary) {
-        LOG(ERROR) << "Failed to load EGL: " << libEGLPath.LossyDisplayName();
+    base::NativeLibrary eglLibrary = LoadLibrary(libEGLPath);
+    if (!eglLibrary)
         return false;
-    }
 
     base::FilePath libGLES2Path = toFilePath(QT_LIBDIR_GLES2);
     libGLES2Path = libGLES2Path.Append("libGLESv2.so");
-    base::NativeLibrary gles2Library = gfx::LoadLibrary(libGLES2Path);
-    if (!gles2Library) {
-        LOG(ERROR) << "failed to load GLESv2: " << libGLES2Path.LossyDisplayName();
+    base::NativeLibrary gles2Library = LoadLibrary(libGLES2Path);
+    if (!gles2Library)
         return false;
-    }
 
     gfx::GLGetProcAddressProc get_proc_address = reinterpret_cast<gfx::GLGetProcAddressProc>(base::GetFunctionPointerFromNativeLibrary(eglLibrary, "eglGetProcAddress"));
     if (!get_proc_address) {