Index: /trunk/src/corelib/plugin/plugin.pri
===================================================================
--- /trunk/src/corelib/plugin/plugin.pri	(revision 74)
+++ /trunk/src/corelib/plugin/plugin.pri	(revision 75)
@@ -20,4 +20,8 @@
 }
 
+os2 {
+	SOURCES += plugin/qlibrary_os2.cpp
+}
+
 unix {
 	SOURCES += plugin/qlibrary_unix.cpp
Index: /trunk/src/corelib/plugin/qlibrary_os2.cpp
===================================================================
--- /trunk/src/corelib/plugin/qlibrary_os2.cpp	(revision 75)
+++ /trunk/src/corelib/plugin/qlibrary_os2.cpp	(revision 75)
@@ -0,0 +1,152 @@
+/***************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** Copyright (C) 2009 netlabs.org. OS/2 parts.
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qplatformdefs.h"
+#include "qlibrary_p.h"
+#include "qfile.h"
+#include "qdir.h"
+#include "qfileinfo.h"
+#include "qdir.h"
+
+#ifndef QT_NO_LIBRARY
+
+QT_BEGIN_NAMESPACE
+
+// provide human readable strings for common OS/2 DOS errors
+// @todo make exported if needed anywhere else
+static QString qt_os2_error_string(APIRET code)
+{
+    // see qt_error_string()
+
+    const char *s = 0;
+    QString ret;
+
+    switch (code) {
+        case NO_ERROR:
+            return ret;
+        case ERROR_FILE_NOT_FOUND:
+            s = QT_TRANSLATE_NOOP("QIODevice", "File not found");
+            break;
+        case ERROR_PATH_NOT_FOUND:
+            s = QT_TRANSLATE_NOOP("QIODevice", "Path not found");
+            break;
+        case ERROR_TOO_MANY_OPEN_FILES:
+            return qt_error_string(EMFILE);
+        case ERROR_ACCESS_DENIED:
+            s = QT_TRANSLATE_NOOP("QIODevice", "Access denied");
+            break;
+        case ERROR_SHARING_VIOLATION:
+            s = QT_TRANSLATE_NOOP("QIODevice", "Sharing violation");
+            break;
+        default:
+            break;
+    }
+
+    if (s)
+        // ######## this breaks moc build currently
+//         ret = QCoreApplication::translate("QIODevice", s);
+        ret = QString::fromLatin1(s);
+    else
+        // ######## this breaks moc build currently
+//         ret = QString(QCoreApplication::translate("QIODevice","System error %1")).arg(code);
+        ret = QString::fromLatin1("System error %1").arg(code);
+    return ret;
+}
+
+bool QLibraryPrivate::load_sys()
+{
+    pHnd = 0;
+
+    QByteArray attempt = QFile::encodeName(QDir::toNativeSeparators(fileName));
+
+    APIRET rc;
+    char errModule[CCHMAXPATH] = { '\0' };
+    rc = DosLoadModule(errModule, sizeof(errModule), attempt, &pHnd);
+    if (rc == ERROR_FILE_NOT_FOUND) {
+        attempt += ".DLL";
+        rc = DosLoadModule(errModule, sizeof(errModule), attempt, &pHnd);
+    }
+
+    if (rc != NO_ERROR) {
+        errorString = QLibrary::tr("Cannot load library %1: %2")
+            .arg(fileName).arg(qt_os2_error_string(rc));
+        if (*errModule != '\0')
+            errorString += QLibrary::tr(" (failed module: %1)").arg(errModule);
+        return false;
+    }
+
+    errorString.clear();
+    rc = DosQueryModuleName(pHnd, sizeof(errModule), errModule);
+    Q_ASSERT(rc == NO_ERROR);
+
+    qualifiedFileName = QDir::fromNativeSeparators(QFile::decodeName(QByteArray(errModule)));
+
+    return true;
+}
+
+bool QLibraryPrivate::unload_sys()
+{
+    APIRET rc = DosFreeModule(pHnd);
+    if (rc != NO_ERROR) {
+        errorString = QLibrary::tr("Cannot unload library %1: %2").arg(fileName).arg(qt_os2_error_string(rc));
+        return false;
+    }
+    errorString.clear();
+    return true;
+}
+
+void* QLibraryPrivate::resolve_sys(const char* symbol)
+{
+    void *address = 0;
+    APIRET rc = DosQueryProcAddr(pHnd, 0, symbol, (PFN*) &address);
+    if (rc != NO_ERROR) {
+        errorString = QLibrary::tr("Cannot resolve symbol \"%1\" in %2: %3").arg(
+            QString::fromAscii(symbol)).arg(fileName).arg(qt_os2_error_string(rc));
+    } else {
+        errorString.clear();
+    }
+    return address;
+}
+QT_END_NAMESPACE
+
+#endif // QT_NO_LIBRARY
Index: /trunk/src/corelib/plugin/qlibrary_p.h
===================================================================
--- /trunk/src/corelib/plugin/qlibrary_p.h	(revision 74)
+++ /trunk/src/corelib/plugin/qlibrary_p.h	(revision 75)
@@ -54,6 +54,8 @@
 //
 
-#ifdef Q_WS_WIN
+#if defined(Q_WS_WIN)
 # include "QtCore/qt_windows.h"
+#elif defined(Q_OS_OS2)
+# include "QtCore/qt_os2.h"
 #endif
 #include "QtCore/qlibrary.h"
@@ -73,6 +75,8 @@
 public:
 
-#ifdef Q_WS_WIN
+#if defined(Q_WS_WIN)
     HINSTANCE
+#elif defined(Q_OS_OS2)
+    HMODULE
 #else
     void *
