PDA

View Full Version : Setting Default directory for libraries in Qt Creator



manaila
1st March 2012, 14:47
Hi,

When I run my application which accesses MySQL database using Qt Creator, I get the "QSqlDatabase: QMYSQL driver not loaded" error. But when I compile and run it on the terminal (I am using Ubuntu 11.04), it works fine.
When I checked the two makefiles (one generated by Qt Creator & the other by qmake on the terminal), there are differences in the directories for LIBS and INCPATH as shown below:

Makefile by Qt Creator
...
INCPATH = -I/opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/linux-g++ -I../MyProject -I/opt/QtSDK/Desktop/Qt/473/gcc/include/QtCore -I/opt/QtSDK/Desktop/Qt/473/gcc/include/QtGui -I/opt/QtSDK/Desktop/Qt/473/gcc/include/QtSql -I/opt/QtSDK/Desktop/Qt/473/gcc/include -I../MyPoject -I. -I.
LIBS = $(SUBLIBS) -L/opt/QtSDK/Desktop/Qt/473/gcc/lib -lQtSql -lQtGui -lQtCore -lpthread
...

Makefile by terminal
INCPATH = -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtSql -I/usr/include/qt4 -I. -I.
LIBS = $(SUBLIBS) -L/usr/lib -lQtSql -lQtGui -lQtCore -lpthread


So my question is how can I make Qt creator to generate the same makefile as the one generated from the terminal, i.e make Qt Creator to "see" the MySQL libraries directory which is /usr/lib/qt4/plugins/sqldrivers?

ChrisW67
2nd March 2012, 02:07
Create a build configuration (under Projects) that uses "Qt in PATH" rather than the specific version you have it using now. You can adjust the available Qt versions from the Options dialog.

manaila
2nd March 2012, 07:07
It worked, thank you!