nurtsi
15th September 2007, 10:32
I have a little app that uses the SQL module from qt. I can compile (and run) this app fine on Ubuntu (where the qt lib is apparently built without plugins).
When I first tried my app in Gentoo, it compiled fine, but didn't find the SQL drivers during run-time (since they are compiled as plugins in Gentoo). I tried to convert my app to use the plugin approach (Added Q_IMPORT_PLUGIN to my code and QTPLUGINS to project), but now I get this error during linking:
g++ -o ../../logind Main.cpp -L../../lib -L/usr/lib/qt4 -lsockets -lssl -lcommon -lsrp -ldotconfpp -L/usr/lib/qt4/plugins/sqldrivers/ -lqsqlmysql -lQtSql -L/usr/lib/mysql -L/usr/lib/qt4 -lQtCore -lz -lm -lrt -ldl -lpthread
Main.o: In function `StaticqsqlmysqlPluginInstance':
Main.cpp:71: undefined reference to `qt_plugin_instance_qsqlmysql()'
collect2: ld returned 1 exit status
make: *** [../../logind] Error 1
The offending line in Main.cpp is:
Q_IMPORT_PLUGIN(qsqlmysql);
My project file for the app is:
SOURCES += Main.cpp
INCLUDEPATH += ../
LIBPATH += ../../lib
LIBS += -lsockets -lssl -lcommon -lsrp -ldotconfpp
QT = core sql
QTPLUGIN += qsqlmysql
CONFIG += debug
TARGET = ../../logind
I have libqsqlmysql.so in /usr/lib/qt4/plugins/sqldrivers.
For what it's worth, I use qt 4.3.1 and it was configured with the following:
./configure -stl -verbose -largefile -confirm-license -platform linux-g++ -xplatform linux-g++ -no-rpath -prefix /usr -bindir /usr/bin -libdir /usr/lib/qt4 -datadir /usr/share/qt4 -docdir /usr/share/doc/qt-4.3.1-r1 -headerdir /usr/include/qt4 -plugindir /usr/lib/qt4/plugins -sysconfdir /etc/qt4 -translationdir /usr/share/qt4/translations -examplesdir /usr/share/qt4/examples -demosdir /usr/share/qt4/demos -reduce-relocations -no-accessibility -cups -no-xinerama -opengl -no-nis -qt-gif -system-libpng -system-libjpeg -system-libtiff -system-zlib -no-libmng -release -no-separate-debug-info -plugin-sql-mysql -I/usr/include/mysql -L/usr/lib/mysql -no-sql-psql -no-sql-ibase -no-sql-sqlite -no-sql-sqlite2 -no-sql-odbc -qdbus -no-glib -no-qt3support -openssl -no-pch -no-tablet -xrender -xrandr -xkb -xshape -sm -nomake examples
From what library should `qt_plugin_instance_qsqlmysql()' come from? Or is there something else wrong in my approach?
When I first tried my app in Gentoo, it compiled fine, but didn't find the SQL drivers during run-time (since they are compiled as plugins in Gentoo). I tried to convert my app to use the plugin approach (Added Q_IMPORT_PLUGIN to my code and QTPLUGINS to project), but now I get this error during linking:
g++ -o ../../logind Main.cpp -L../../lib -L/usr/lib/qt4 -lsockets -lssl -lcommon -lsrp -ldotconfpp -L/usr/lib/qt4/plugins/sqldrivers/ -lqsqlmysql -lQtSql -L/usr/lib/mysql -L/usr/lib/qt4 -lQtCore -lz -lm -lrt -ldl -lpthread
Main.o: In function `StaticqsqlmysqlPluginInstance':
Main.cpp:71: undefined reference to `qt_plugin_instance_qsqlmysql()'
collect2: ld returned 1 exit status
make: *** [../../logind] Error 1
The offending line in Main.cpp is:
Q_IMPORT_PLUGIN(qsqlmysql);
My project file for the app is:
SOURCES += Main.cpp
INCLUDEPATH += ../
LIBPATH += ../../lib
LIBS += -lsockets -lssl -lcommon -lsrp -ldotconfpp
QT = core sql
QTPLUGIN += qsqlmysql
CONFIG += debug
TARGET = ../../logind
I have libqsqlmysql.so in /usr/lib/qt4/plugins/sqldrivers.
For what it's worth, I use qt 4.3.1 and it was configured with the following:
./configure -stl -verbose -largefile -confirm-license -platform linux-g++ -xplatform linux-g++ -no-rpath -prefix /usr -bindir /usr/bin -libdir /usr/lib/qt4 -datadir /usr/share/qt4 -docdir /usr/share/doc/qt-4.3.1-r1 -headerdir /usr/include/qt4 -plugindir /usr/lib/qt4/plugins -sysconfdir /etc/qt4 -translationdir /usr/share/qt4/translations -examplesdir /usr/share/qt4/examples -demosdir /usr/share/qt4/demos -reduce-relocations -no-accessibility -cups -no-xinerama -opengl -no-nis -qt-gif -system-libpng -system-libjpeg -system-libtiff -system-zlib -no-libmng -release -no-separate-debug-info -plugin-sql-mysql -I/usr/include/mysql -L/usr/lib/mysql -no-sql-psql -no-sql-ibase -no-sql-sqlite -no-sql-sqlite2 -no-sql-odbc -qdbus -no-glib -no-qt3support -openssl -no-pch -no-tablet -xrender -xrandr -xkb -xshape -sm -nomake examples
From what library should `qt_plugin_instance_qsqlmysql()' come from? Or is there something else wrong in my approach?