PDA

View Full Version : QT QSqlDatabase: QSQLITE driver not loaded MAC



migel
1st July 2011, 17:13
Anyone know how to get this working on mac ?

So far I have tried

main.cpp

#ifdef Q_WS_MAC
QDir dir(QApplication::applicationDirPath());
dir.cdUp();
dir.cd("plugins");
QApplication::addLibraryPath(QStringList(dir.absol utePath()));
#endif


db = QSqlDatabase::addDatabase("QSQLITE");


mkdir App.app/Contents/plugins
mkdir App.app/Contents/plugins/sqldrivers
cp /Developer/Qt/Desktop/Qt/473/gcc/plugins/sqldrivers/libqsqlite.dylib App.app/Contents/plugins/sqldrivers/.

install_name_tool -id @executable_path/../plugins/sqldrivers/libqsqlite.dylib App.app/Contents/plugins/sqldrivers/libqsqlite.dylib
install_name_tool -change /Developer/Qt/Desktop/Qt/473/gcc/lib/QtSql.framework/Versions/4/QtSql @executable_path/../Frameworks/QtSql.framework/Versions/Current/QtSql App.app/Contents/plugins/sqldrivers/libqsqlite.dylib
install_name_tool -change /Developer/Qt/Desktop/Qt/473/gcc/lib/QtCore.framework/Versions/4/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/Current/QtCore App.app/Contents/plugins/sqldrivers/libqsqlite.dylib



QT += network webkit xml sql declarative script svg

Thanks for pointing me with any direction

mcosta
1st July 2011, 17:38
Try reading this Current working directory.

I never tried in Mac but in Windows works.

Many official Qt Examples use the same code

migel
1st July 2011, 17:56
qt.conf


[Paths]
Plugins = ./plugins

This is how to load the plugin