PDA

View Full Version : Build issue



Ashkan_s
23rd September 2012, 15:10
I am trying to repeat the example described at qsqldatabase.html#addDatabase-2 with sqlite but at the first step I cannot build a test program.

Building this code:

#include <QtGui/QApplication>

#include "../src/sql/drivers/sqlite/qsql_sqlite.cpp"

int main(int argc, char *argv[])
{
QApplication app(argc, argv);

QSQLiteDriver *drv = new QSQLiteDriver();

return app.exec();
}

results many lines of errors here is first lines:

In file included from ..\untitled4\main.cpp:3:

d:\QT\2010.05\qt\include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:60:21: error: sqlite3.h: No such file or directory

In file included from ..\untitled4\main.cpp:3:

d:\QT\2010.05\qt\include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:63: error: 'sqlite3_stmt' was not declared in this scope

d:\QT\2010.05\qt\include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:63: error: template argument 1 is invalid

In file included from ..\untitled4\main.cpp:3:

d:\QT\2010.05\qt\include/../src/sql/drivers/sqlite/qsql_sqlite.cpp: In function 'QSqlError qMakeError(sqlite3*, const QString&, QSqlError::ErrorType, int)':

d:\QT\2010.05\qt\include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:98: error: 'sqlite3_errmsg16' was not declared in this scope

To inform the compiler of the location of sqlite3.h I added this:

INCLUDEPATH += "D:\QT\2010.05\qt\src\3rdparty\sqlite"
to the .pro file
Now it looks like:

QT += sql

SOURCES += \
main.cpp \

INCLUDEPATH += "D:\QT\2010.05\qt\src\3rdparty\sqlite"

Now it give some "undefined reference" errors and warnings about something "redeclared without dllimport attribute: previous dllimport ignored"

here is the compile output (shortened to fit):

Running build steps for project untitled4...
Configuration unchanged, skipping qmake step.
Starting: "D:/QT/2010.05/mingw/bin/mingw32-make.exe" -w
mingw32-make: Entering directory `C:/Documents and Settings/2/My Documents/qt-projects/untitled4-build-desktop'

d:\qt\2010.05\qt\bin\qmake.exe -spec d:\QT\2010.05\qt\mkspecs\win32-g++ -o Makefile ..\untitled4\untitled4.pro

mingw32-make: Leaving directory `C:/Documents and Settings/2/My Documents/qt-projects/untitled4-build-desktop'

WARNING: c:\Documents and Settings\2\My Documents\qt-projects\untitled4\untitled4.pro:6: Unescaped backslashes are deprecated.

WARNING: c:\Documents and Settings\2\My Documents\qt-projects\untitled4\untitled4.pro:6: Unescaped backslashes are deprecated.

WARNING: c:\Documents and Settings\2\My Documents\qt-projects\untitled4\untitled4.pro:6: Unescaped backslashes are deprecated.

mingw32-make: Entering directory `C:/Documents and Settings/2/My Documents/qt-projects/untitled4-build-desktop'

D:/QT/2010.05/mingw/bin/mingw32-make -f Makefile.Debug

mingw32-make[1]: Entering directory `C:/Documents and Settings/2/My Documents/qt-projects/untitled4-build-desktop'

g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_SQL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"d:\QT\2010.05\qt\include\QtCore" -I"d:\QT\2010.05\qt\include\QtGui" -I"d:\QT\2010.05\qt\include\QtSql" -I"d:\QT\2010.05\qt\include" -I"d:\QT\2010.05\qt\src\3rdparty\sqlite" -I"d:\QT\2010.05\qt\include\ActiveQt" -I"debug" -I"..\untitled4" -I"." -I"d:\QT\2010.05\qt\mkspecs\win32-g++" -o debug\main.o ..\untitled4\main.cpp

In file included from ..\untitled4\main.cpp:3:

d:\QT\2010.05\qt\include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:460: warning: 'QSQLiteDriver::QSQLiteDriver(QObject*)' redeclared without dllimport attribute: previous dllimport ignored

.
.
.

d:\QT\2010.05\qt\include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:698: warning: 'virtual QVariant QSQLiteDriver::handle() const' redeclared without dllimport attribute: previous dllimport ignored

d:\QT\2010.05\qt\include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:703: warning: 'virtual QString QSQLiteDriver::escapeIdentifier(const QString&, QSqlDriver::IdentifierType) const' redeclared without dllimport attribute: previous dllimport ignored

..\untitled4\main.cpp: In function 'int qMain(int, char**)':

..\untitled4\main.cpp:9: warning: unused variable 'drv'

g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -Wl,-subsystem,windows -o debug\untitled4.exe debug/main.o -L"d:\QT\2010.05\qt\lib" -lmingw32 -lqtmaind -lQtSqld4 -lQtGuid4 -lQtCored4

mingw32-make[1]: Leaving directory `C:/Documents and Settings/2/My Documents/qt-projects/untitled4-build-desktop'

mingw32-make: Leaving directory `C:/Documents and Settings/2/My Documents/qt-projects/untitled4-build-desktop'

debug/main.o: In function `qMakeError':

d:/QT/2010.05/qt/include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:99: undefined reference to `sqlite3_errmsg16'

debug/main.o:d:/QT/2010.05/qt/include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:152: undefined reference to `sqlite3_finalize'

debug/main.o:d:/QT/2010.05/qt/include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:158: undefined reference to `sqlite3_column_count'
.
.
.
.
.

debug/main.o:d:/QT/2010.05/qt/include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:439: undefined reference to `sqlite3_last_insert_rowid'

debug/main.o: In function `QSQLiteDriver':

d:/QT/2010.05/qt/include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:461: undefined reference to `_imp___ZTV13QSQLiteDriver'

d:/QT/2010.05/qt/include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:461: undefined reference to `_imp___ZTV13QSQLiteDriver'

d:/QT/2010.05/qt/include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:467: undefined reference to `_imp___ZTV13QSQLiteDriver'

d:/QT/2010.05/qt/include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:467: undefined reference to `_imp___ZTV13QSQLiteDriver'

debug/main.o: In function `~QSQLiteDriver':

d:/QT/2010.05/qt/include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:476: undefined reference to `_imp___ZTV13QSQLiteDriver'

debug/main.o:d:/QT/2010.05/qt/include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:476: more undefined references to `_imp___ZTV13QSQLiteDriver' follow

debug/main.o:d:/QT/2010.05/qt/include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:531: undefined reference to `sqlite3_enable_shared_cache'

debug/main.o:d:/QT/2010.05/qt/include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:533: undefined reference to `sqlite3_open_v2'

debug/main.o:d:/QT/2010.05/qt/include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:534: undefined reference to `sqlite3_busy_timeout'

debug/main.o:d:/QT/2010.05/qt/include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:549: undefined reference to `sqlite3_close'

debug/main.o:d:/QT/2010.05/qt/include/../src/sql/drivers/sqlite/qsql_sqlite.h:90: undefined reference to `_imp___ZN13QSQLiteDriver16staticMetaObjectE'

collect2: ld returned 1 exit status

mingw32-make[1]: *** [debug\untitled4.exe] Error 1

mingw32-make: *** [debug] Error 2

The process "D:/QT/2010.05/mingw/bin/mingw32-make.exe" exited with code %2.
Error while building project untitled4 (target: Desktop)
When executing build step 'Make'

Can anyone guide me how to identify and solve the problem?

Robbie
23rd September 2012, 17:39
The documentation of this unusual way of dealing with database drivers notes that you need to compile against the client library of the driver. The error messages pertaining to "undefined reference to ..." indicate that you've not done this. You need to find the SQLite3 static library and add that to the LIBS and LIBRARYPATH variables in your .pro file.

Ashkan_s
24th September 2012, 09:05
The documentation sql-driver.html says to build SQLite3 statically into my Qt library I need to run following command:

configure -qt-sql-sqlite

In the documentation I cannot find anything about running mingw32-make in case of SQLite3. After running the configure script it showed a message saying to build you just need to run mingw32-make and I did that. After hours of compiling and creating and replacing dlls (I think for all the SDK) it stopped with an error.

Now my question is: Did I follow the procedure correctly? I mean, to build SQLite3 is it needed to build all the SDK or I have done wrong?

Before I forget, I am using a pre-compiled version of the Qt SDK.

Ashkan_s
25th September 2012, 15:38
I found this (http://www.mimec.org/node/296), did what was suggested and problems solved.