Results 1 to 4 of 4

Thread: Build issue

  1. #1
    Join Date
    Sep 2012
    Location
    Iran, Tehran
    Posts
    76
    Thanks
    17
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Question Build issue

    I am trying to repeat the example described at http://doc.qt.io/qt-4.8/qsqldatabase.html#addDatabase-2 with sqlite but at the first step I cannot build a test program.

    Building this code:
    Qt Code:
    1. #include <QtGui/QApplication>
    2.  
    3. #include "../src/sql/drivers/sqlite/qsql_sqlite.cpp"
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QApplication app(argc, argv);
    8.  
    9. QSQLiteDriver *drv = new QSQLiteDriver();
    10.  
    11. return app.exec();
    12. }
    To copy to clipboard, switch view to plain text mode 

    results many lines of errors here is first lines:
    Qt Code:
    1. In file included from ..\untitled4\main.cpp:3:
    2.  
    3. d:\QT\2010.05\qt\include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:60:21: error: sqlite3.h: No such file or directory
    4.  
    5. In file included from ..\untitled4\main.cpp:3:
    6.  
    7. d:\QT\2010.05\qt\include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:63: error: 'sqlite3_stmt' was not declared in this scope
    8.  
    9. d:\QT\2010.05\qt\include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:63: error: template argument 1 is invalid
    10.  
    11. In file included from ..\untitled4\main.cpp:3:
    12.  
    13. d:\QT\2010.05\qt\include/../src/sql/drivers/sqlite/qsql_sqlite.cpp: In function 'QSqlError qMakeError(sqlite3*, const QString&, QSqlError::ErrorType, int)':
    14.  
    15. d:\QT\2010.05\qt\include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:98: error: 'sqlite3_errmsg16' was not declared in this scope
    To copy to clipboard, switch view to plain text mode 

    To inform the compiler of the location of sqlite3.h I added this:
    Qt Code:
    1. INCLUDEPATH += "D:\QT\2010.05\qt\src\3rdparty\sqlite"
    To copy to clipboard, switch view to plain text mode 
    to the .pro file
    Now it looks like:
    Qt Code:
    1. QT += sql
    2.  
    3. SOURCES += \
    4. main.cpp \
    5.  
    6. INCLUDEPATH += "D:\QT\2010.05\qt\src\3rdparty\sqlite"
    To copy to clipboard, switch view to plain text mode 

    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):
    Qt Code:
    1. Running build steps for project untitled4...
    2. Configuration unchanged, skipping qmake step.
    3. Starting: "D:/QT/2010.05/mingw/bin/mingw32-make.exe" -w
    4. mingw32-make: Entering directory `C:/Documents and Settings/2/My Documents/qt-projects/untitled4-build-desktop'
    5.  
    6. d:\qt\2010.05\qt\bin\qmake.exe -spec d:\QT\2010.05\qt\mkspecs\win32-g++ -o Makefile ..\untitled4\untitled4.pro
    7.  
    8. mingw32-make: Leaving directory `C:/Documents and Settings/2/My Documents/qt-projects/untitled4-build-desktop'
    9.  
    10. WARNING: c:\Documents and Settings\2\My Documents\qt-projects\untitled4\untitled4.pro:6: Unescaped backslashes are deprecated.
    11.  
    12. WARNING: c:\Documents and Settings\2\My Documents\qt-projects\untitled4\untitled4.pro:6: Unescaped backslashes are deprecated.
    13.  
    14. WARNING: c:\Documents and Settings\2\My Documents\qt-projects\untitled4\untitled4.pro:6: Unescaped backslashes are deprecated.
    15.  
    16. mingw32-make: Entering directory `C:/Documents and Settings/2/My Documents/qt-projects/untitled4-build-desktop'
    17.  
    18. D:/QT/2010.05/mingw/bin/mingw32-make -f Makefile.Debug
    19.  
    20. mingw32-make[1]: Entering directory `C:/Documents and Settings/2/My Documents/qt-projects/untitled4-build-desktop'
    21.  
    22. 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
    23.  
    24. In file included from ..\untitled4\main.cpp:3:
    25.  
    26. 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
    27.  
    28. .
    29. .
    30. .
    31.  
    32. 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
    33.  
    34. 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
    35.  
    36. ..\untitled4\main.cpp: In function 'int qMain(int, char**)':
    37.  
    38. ..\untitled4\main.cpp:9: warning: unused variable 'drv'
    39.  
    40. 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
    41.  
    42. mingw32-make[1]: Leaving directory `C:/Documents and Settings/2/My Documents/qt-projects/untitled4-build-desktop'
    43.  
    44. mingw32-make: Leaving directory `C:/Documents and Settings/2/My Documents/qt-projects/untitled4-build-desktop'
    45.  
    46. debug/main.o: In function `qMakeError':
    47.  
    48. d:/QT/2010.05/qt/include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:99: undefined reference to `sqlite3_errmsg16'
    49.  
    50. debug/main.o:d:/QT/2010.05/qt/include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:152: undefined reference to `sqlite3_finalize'
    51.  
    52. debug/main.o:d:/QT/2010.05/qt/include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:158: undefined reference to `sqlite3_column_count'
    53. .
    54. .
    55. .
    56. .
    57. .
    58.  
    59. debug/main.o:d:/QT/2010.05/qt/include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:439: undefined reference to `sqlite3_last_insert_rowid'
    60.  
    61. debug/main.o: In function `QSQLiteDriver':
    62.  
    63. d:/QT/2010.05/qt/include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:461: undefined reference to `_imp___ZTV13QSQLiteDriver'
    64.  
    65. d:/QT/2010.05/qt/include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:461: undefined reference to `_imp___ZTV13QSQLiteDriver'
    66.  
    67. d:/QT/2010.05/qt/include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:467: undefined reference to `_imp___ZTV13QSQLiteDriver'
    68.  
    69. d:/QT/2010.05/qt/include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:467: undefined reference to `_imp___ZTV13QSQLiteDriver'
    70.  
    71. debug/main.o: In function `~QSQLiteDriver':
    72.  
    73. d:/QT/2010.05/qt/include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:476: undefined reference to `_imp___ZTV13QSQLiteDriver'
    74.  
    75. debug/main.o:d:/QT/2010.05/qt/include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:476: more undefined references to `_imp___ZTV13QSQLiteDriver' follow
    76.  
    77. debug/main.o:d:/QT/2010.05/qt/include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:531: undefined reference to `sqlite3_enable_shared_cache'
    78.  
    79. debug/main.o:d:/QT/2010.05/qt/include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:533: undefined reference to `sqlite3_open_v2'
    80.  
    81. debug/main.o:d:/QT/2010.05/qt/include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:534: undefined reference to `sqlite3_busy_timeout'
    82.  
    83. debug/main.o:d:/QT/2010.05/qt/include/../src/sql/drivers/sqlite/qsql_sqlite.cpp:549: undefined reference to `sqlite3_close'
    84.  
    85. debug/main.o:d:/QT/2010.05/qt/include/../src/sql/drivers/sqlite/qsql_sqlite.h:90: undefined reference to `_imp___ZN13QSQLiteDriver16staticMetaObjectE'
    86.  
    87. collect2: ld returned 1 exit status
    88.  
    89. mingw32-make[1]: *** [debug\untitled4.exe] Error 1
    90.  
    91. mingw32-make: *** [debug] Error 2
    92.  
    93. The process "D:/QT/2010.05/mingw/bin/mingw32-make.exe" exited with code %2.
    94. Error while building project untitled4 (target: Desktop)
    95. When executing build step 'Make'
    To copy to clipboard, switch view to plain text mode 

    Can anyone guide me how to identify and solve the problem?
    Last edited by Ashkan_s; 23rd September 2012 at 15:14.

  2. #2
    Join Date
    Jun 2010
    Location
    Pretoria, South Africa
    Posts
    22
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Build issue

    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.

  3. The following user says thank you to Robbie for this useful post:

    Ashkan_s (16th October 2012)

  4. #3
    Join Date
    Sep 2012
    Location
    Iran, Tehran
    Posts
    76
    Thanks
    17
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Build issue

    The documentation http://doc.qt.io/qt-4.8/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.

  5. #4
    Join Date
    Sep 2012
    Location
    Iran, Tehran
    Posts
    76
    Thanks
    17
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Post Re: Build issue

    I found this, did what was suggested and problems solved.

Similar Threads

  1. Replies: 3
    Last Post: 11th November 2012, 21:17
  2. QMYSQL Build Issue -Qt 4.8.0 MSVC 2010-
    By s7 in forum Qt Programming
    Replies: 1
    Last Post: 20th May 2012, 20:22
  3. Replies: 0
    Last Post: 4th November 2011, 13:53
  4. gmake embedded ARM build issue
    By proteus1 in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 6th January 2011, 20:43
  5. QT4 Embedded custom build issue
    By nikel in forum Installation and Deployment
    Replies: 0
    Last Post: 26th November 2010, 20:03

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.