[Qt-interest] questions about QODBC

yanqzhi at gmail.com yanqzhi at gmail.com
Wed Sep 9 04:55:24 CEST 2009


hi,everyone :

I am writing a test progranm about QODBC using Qt 4.5. When the progranm run in a coumputer on which Qt is not installed,"Driver not loaded" was displayed.I have tried methods what I could found, but I could not solved it.

I tried dll:
1.I placed the qsqlodbc4.dll in my application's directory(app) .
2.I placed the qsqlodbc4.dll in app/plugins. 
3.I placed the qsqlodbc4.dll in app/sqldrivers.
4.I placed the qsqlodbc4.dll in app/plugins/sqldrivers.

I tried lib
Add Q_IMPORT_PLUGIN(qsqlodbc) in code
Add QTPLUGIN     += qsqlodbc in .pro
but when I compiled the program, "undefined reference to 'qt_plugin_instance_qsqlodbc()'" was displayed.

I tried  QPluginLoader 
 QString str = QApplication::applicationDirPath() + QDir::separator() + "plugins";
 QDir dir = QDir( QApplication::applicationDirPath() + QDir::separator() + "plugins");
 foreach (QString fileName, dir.entryList(QDir::Files))
 {
  QPluginLoader loader(dir.absoluteFilePath(fileName));
  QObject *plugin = loader.instance();
  if (plugin) 
  {
   int n = 0;
  }
 }
when I debuged the progarm,
bool QPluginLoader::load()
{
    if (!d || d->fileName.isEmpty())
        return false;
    if (did_load)
        return d->pHnd && d->instance;
    if (!d->isPlugin())
        return false;
    did_load = true;
    return d->loadPlugin();
}
 at below row return false (qsqlodbc.dll was loaded)
 if (!d->isPlugin())
        return false;

best regards


         
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090909/4fa962a7/attachment.html 


More information about the Qt-interest-old mailing list