PDA

View Full Version : QSqlDatabase Link error



scotty2012
3rd August 2009, 16:13
Hi. I'm new to Qt, but have decent experience in C++. I am trying to use QSqlDatabase to connection to MSSQL over an ODBC connection. I've verified I'm linking with QtSqld4.lib and have included QtSql in my app.

The problem I am having is this:


Error 3 error LNK2001: unresolved external symbol "public: static char * QSqlDatabase::defaultConnection" (?defaultConnection@QSqlDatabase@@2PADA) check_db.obj restorer
Error 4 error LNK2001: unresolved external symbol "private: static struct QString::Data QString::shared_null" (?shared_null@QString@@0UData@1@A) check_db.obj restorer

spirit
3rd August 2009, 16:24
did you add QT += sql in you pro-file?

scotty2012
3rd August 2009, 16:32
I am using VS2008, so I don't think I have a .pro file (well, I know I DON'T have one now). Should I add one? how is it supposed to be name?

spirit
3rd August 2009, 16:43
well, when you create a new project you should run
qmake -project in the project directory (this commad creates a Qt's project file, i.e. pro-file), then you should add QT += sql to unable SQL support in QT, then run
qmake -t vcapp (this commad create vcproj-file), now you can run your project in VS by calling
devenv <project_name>.vcproj or by double-clicking on <project_name>.vcproj.

scotty2012
3rd August 2009, 16:56
well, building it using qmake and nmake works, but it's still broken in Visual Studio