Results 1 to 4 of 4

Thread: undefined reference to `_imp___Z*****

  1. #1
    Join Date
    Jan 2007
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default undefined reference to `_imp___Z*****

    Qt 4.2.2 with MinGW 3.4.2 (make is GNU 3.8) on XPpro SP2:
    I'm trying a simple program that would connect through ODBC to my MSSQL200 server that runs on my machine;
    the C:\Qt\4.2.2\demos\sqlbrowser\release\sqlbrowser.ex e does it perfectly but i want to do my own;

    qmake -project and qmake -o Makefile -SQLTest.pro run Ok but after that the "make" first tells me: QtSql - no such file or directory and then after I insert in the Makefile.Debug the "-I"C:/Qt/4.2.2/include/QtSql" it returns a bunch of:

    "undefined reference to `_imp___Z*****QSqlDatabase'"

    here is my 2 source files:
    main.cpp:

    Qt Code:
    1. #include <QtGui>
    2. #include <QtSql>
    3. #include <QSqlDatabase>
    4. #include <QSqlError>
    5. #include <QSqlError>
    6.  
    7. #include "connection.h"
    8.  
    9. int main(int argc, char *argv[])
    10. {
    11. QApplication app(argc, argv);
    12. if (!createConnection()) {
    13. return 1;}
    14. return app.exec();
    15. }
    To copy to clipboard, switch view to plain text mode 

    and connection.h:

    Qt Code:
    1. #ifndef CONNECTION_H
    2. #define CONNECTION_H
    3.  
    4. #include <QMessageBox>
    5. #include <QSqlDatabase>
    6.  
    7. inline bool createConnection()
    8. {
    9.  
    10. QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
    11. db.setHostName("localhost");
    12. db.setDatabaseName("mydb");
    13. db.setUserName("sa");
    14. db.setPassword("password");
    15.  
    16. if (!db.open()) {
    17. QMessageBox::warning(0, QObject::tr("Database Connection Error"),
    18. db.lastError().text());
    19. return false;
    20. }
    21. return true;
    22. }
    23. #endif
    To copy to clipboard, switch view to plain text mode 

    make gives me exact same message even if i try to copy the entire contents of C:\Qt\4.2.2\demos\sqlbrowser\ into a different directory (how did it copile at install to begin with??)
    my path is: "PATH=C:\Qt\4.2.2\bin;C:\Qt\4.2.2\lib;C:\Qt\4.2.2\ include;C:\MinGW\bin;C:\WINDOWS\System32"

    any ideas?
    Last edited by wysota; 17th January 2007 at 22:06. Reason: missing [code] tags

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: undefined reference to `_imp___Z*****

    To link against the QtSql module, add this line to your qmake .pro file:
    QT += sql
    Note: you must re-run qmake after modifying the .pro file to generate the new makefile.
    J-P Nurmi

  3. #3
    Join Date
    Jan 2007
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: undefined reference to `_imp___Z*****

    thanks, it worked;
    just curious: without having to do it manually, is there a way to tell qt to place that line 'QT += sql' in the .pro file every time i qmake -project when including <QtSql> (or if i have to delete and re-create the .pro file)?

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: undefined reference to `_imp___Z*****

    It is advisable to run "qmake -project" only once in the beginning of the project and then modify the project file by hand afterwards. There are also free IDEs out there which can handle qmake project files for you. If you're interested, take a look around the forums..
    J-P Nurmi

Similar Threads

  1. how to correctly compile threads support?
    By srhlefty in forum Installation and Deployment
    Replies: 9
    Last Post: 25th June 2006, 19:15
  2. Strange error while using Q3Canvas
    By Kapil in forum Newbie
    Replies: 13
    Last Post: 15th June 2006, 19:36
  3. I got two problems when I used static compiled library of QT4
    By qintm in forum Installation and Deployment
    Replies: 8
    Last Post: 20th April 2006, 08:52
  4. undefined reference to fftw libraries
    By kmyadam in forum General Programming
    Replies: 2
    Last Post: 9th March 2006, 01:01
  5. linking user space and kernel space programs with qmake
    By zielchri in forum Qt Programming
    Replies: 9
    Last Post: 8th March 2006, 23:11

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
  •  
Qt is a trademark of The Qt Company.