Results 1 to 2 of 2

Thread: using qmake for building app which requires non-qt libs.

  1. #1
    Join Date
    Jul 2011
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default using qmake for building app which requires non-qt libs.

    Hello:

    I have legacy code which interfaces with a mysql database using mysql++ mysql connector. ( so using the QT database interfaces is ruled out).
    My job is to build QT User Interfaces which talk to the the mysql++ interfaces and then to the database.
    So this app has both, QT as well as non-QT classes.
    So i wanted to know how to compile , build and run an app that contains QT and non-QT libraries using the qmake system.
    SO to experiment, I wrote the following code snippet which is non-QT based.
    Qt Code:
    1. # include <mysql++.h>
    2. # include <iostream>
    3.  
    4.  
    5. int main (void)
    6. {
    7. mysqlpp::Connection conn(false);
    8. bool isOK;
    9.  
    10. isOK = conn.connect("databasename","localhost","root","root",3306);
    11.  
    12. std::cout << isOK << std::endl;
    13.  
    14. int y;
    15. std::cin >> y;
    16.  
    17. return 0;
    18. }
    To copy to clipboard, switch view to plain text mode 
    The above code returns a 1 upon obtaining a successful connection with the database and 0 if not.
    When I compile, link and run the above code using MSVC all is well and I get 1 as an output in the command prompt.

    Now on to qmake. I want to know if I can get the same result using qmake.
    So I run
    Qt Code:
    1. qmake -project
    To copy to clipboard, switch view to plain text mode 
    and get an output .pro file named mdb.pro ("mdb" is the name of the project).
    I edit the mdb.pro file to contain includepaths and library information. The pro file is as follows:

    Qt Code:
    1. ######################################################################
    2. # Automatically generated by qmake (2.01a) Tue Oct 4 13:35:54 2011
    3. ######################################################################
    4.  
    5. TEMPLATE = app
    6. TARGET =
    7. DEPENDPATH += .
    8. INCLUDEPATH += . C:\\mcpp\\mysql++\\lib C:\\msqlhome\\include
    9. QMAKE_LIBDIR += . C:\\mcpp\\mysql++\\vc2008\\Debug C:\\msqlhome\\lib
    10. LIBS += libmysqld.lib mysqlpp_d.lib
    11.  
    12. # Input
    13. SOURCES += driver.cpp
    To copy to clipboard, switch view to plain text mode 
    As you can see I have edited the .pro file to contain "INCLUDEPATH","QMAKE_LIBDIR"and "LIBS" variables.
    Now I run
    Qt Code:
    1. qmake mdb.pro
    To copy to clipboard, switch view to plain text mode 
    and it runs ok. Then I type nmake and the app compiles and links to produce the executable mdb.exe
    The problem is that on running the executable I get no output. (See attached image).

    So I thought may be something is wrong with the mysql side of things.
    So I wrote the following code:

    Qt Code:
    1. #include <iostream>
    2. int main(void)
    3. {
    4. std::cout << "Hello World" << std::endl;
    5. }
    To copy to clipboard, switch view to plain text mode 

    I ran this code through the "qmake -project" "qmake mdb.pro" "nmake" cycle of commands and all is well and an executable is produced.
    But when I run this executable through the command prompt again I get no output.

    WHat am I doing wrong?
    Attached Images Attached Images

  2. #2
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: using qmake for building app which requires non-qt libs.

    may be add CONFIG += console in your pro file?

Similar Threads

  1. qmake LIBS missing quotes
    By redoctober0 in forum General Programming
    Replies: 1
    Last Post: 12th January 2011, 16:05
  2. qmake LIBS
    By rrlangly in forum Qt Programming
    Replies: 1
    Last Post: 15th July 2010, 00:29
  3. qmake multiple shared libs
    By rrlangly in forum Qt Programming
    Replies: 1
    Last Post: 23rd June 2010, 23:32
  4. Installing libs/headers with qmake
    By ghorwin in forum Qt Programming
    Replies: 2
    Last Post: 7th May 2007, 20:01
  5. qmake, conditioning & bundled libs
    By sebr in forum Qt Programming
    Replies: 3
    Last Post: 29th September 2006, 09:38

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.