Results 1 to 20 of 38

Thread: How to add a lib to a qt project

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2011
    Posts
    26
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to add a lib to a qt project

    I hope I understood it the right way.
    My main() is looking like this now:
    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QApplication a(argc, argv);
    4. a.addLibraryPath("C:/Qt/2010.05/qt/plugins/sqldrivers");
    5. MainWindow w;
    6. w.show();
    7. return a.exec();
    8. }
    To copy to clipboard, switch view to plain text mode 

    But the available drivers are still the same.
    The Question is, how should the software know which dll I need. It just knows where the dlls are located.

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: How to add a lib to a qt project

    No, I mean the "parent" directory for plugins:
    Qt Code:
    1. QApplication::addLibraryPath("C:/Qt/2010.05/qt/plugins"); // without "sqldrivers"
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Feb 2011
    Posts
    26
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to add a lib to a qt project

    sorry, I tried first without "sqldrivers" and after it with "sqldrivers".
    But I qoute the wrong codeline to my reply

  4. #4
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: How to add a lib to a qt project

    So it looks like you'll need to build it indeed - its quite easy, just follow the link ChrisW67 gave you in previous post (there is QPSQL section).

  5. #5
    Join Date
    Feb 2011
    Posts
    26
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to add a lib to a qt project

    I tried to build the psql plugin before,
    but even there I need some support.

    The doc says I have to use these commands

    Qt Code:
    1. cd %QTDIR%\src\plugins\sqldrivers\psql
    2. qmake "INCLUDEPATH+=C:\psql\include" "LIBS+=C:\psql\lib\ms\libpq.lib" psql.pro
    3. nmake
    To copy to clipboard, switch view to plain text mode 

    when I type the second command (yes I used the right path for psql) I get no error but the psql.pro file is still empty.

    when I type the nmake my windows tells me it cannot find nmake. And I can't find nmake in the qt directory either.

    At this point I have to say, thanks for your effort and patience.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to add a lib to a qt project

    I think the "problem" is a missing PostgreSQL dll, not the Qt driver. The driver also needs the dll.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to add a lib to a qt project

    Stampede spake saying:
    The thing is that this plugin is probably already built ( qsqlpsql.dll exisits in his Qt installation ).
    and WilliamSpiderWeb wrote earlier:
    I got the lib from a friend of mine. He used it to communicate to a postgres db with a Visual C++ project (without MFC).
    and gave us error messages from the GNU ld, i.e. the MingW compiler suite.

    It took this to mean that his friend built the plugin with MSVC, and that WilliamSpiderWeb is using MingW. This plugin will not load into a MingW-built program for a variety of reasons. That's why I suggested building the plugin. Perhaps someone else can tell us if PostgreSQL would also have to built with MingW or if the downloadable binaries are sufficient?


    To address one of the plugin build issues...

    nmake is the make utility from the MSVC compiler suite. You are using the MingW compiler bundled in the Qt SDK. The equivalent command would be:
    Qt Code:
    1. mingw32-make
    To copy to clipboard, switch view to plain text mode 

  8. #8
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: How to add a lib to a qt project

    ChrisW67, you are probably right, I just assumed that the qt plugin was built during Qt installation.
    I've just downloaded PostgreSQL from here : link (Binaries from installer version 8.4.7-1 for Windows), and it took me 30 sec. to build the plugin (g++ 4.5.2):
    Qt Code:
    1. cd C:\Qt\src\plugins\sqldrivers\psql
    2. qmake "INCLUDEPATH+=C:\pgsql\include" "LIBS+=C:\pgsql\lib\libpq.lib" psql.pro
    3. make
    To copy to clipboard, switch view to plain text mode 
    Just make sure that path in INCLUDEPATH and LIBS is correct.

  9. #9
    Join Date
    Feb 2011
    Posts
    26
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to add a lib to a qt project

    I'm not sure what I am doing wrong.
    I started cmd, then moved to the directory "..\src\plugin\sqldrivers\psql".
    The psql-folder was just created by me.
    Now I typed the following command.
    Qt Code:
    1. c:\qt\2010.05\qt\qmake\qmake.exe "INCLUDEPATH+=C:\psql9\include" "LIBS+=C:\psql9\lib\libpg.lib" psql.pro
    To copy to clipboard, switch view to plain text mode 
    The error message I get is
    Cannot find file: psql.pro
    When I create an empty textfile or copy an existing *.pro file to the directory "...sqldrivers\psql" I get the following error message
    QMAKESPEC has not been set, so configuration cannot be deduced.
    Error processing project file: psql.pro

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to add a lib to a qt project

    Hmm... sorry for asking but what are you trying to do?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #11
    Join Date
    Feb 2011
    Posts
    26
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to add a lib to a qt project

    Am I on the completly wrong way?

    I want my qt App communicate with a postgresql database.
    Chris and stampede told me I have to build a psql plugin for qt.

    That's what I'm actually trying to do.
    Qt Code:
    1. cd C:\Qt\src\plugins\sqldrivers\psql
    2. qmake "INCLUDEPATH+=C:\pgsql\include" "LIBS+=C:\pgsql\lib\libpq.lib" psql.pro
    3. make
    To copy to clipboard, switch view to plain text mode 

    If I just type qmake, my pc cannot find the command. That's why I typed the whole path of qmake.exe.
    And postgres is installed in C:\psql9 on my computer.
    And as you can read in my last reply, it doesn't work on my computer.

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to add a lib to a qt project

    Quote Originally Posted by WilliamSpiderWeb View Post
    I want my qt App communicate with a postgresql database.
    Chris and stampede told me I have to build a psql plugin for qt.
    And you intend to do it by compiling a project from a directory that doesn't contain any source (nor other project) files? You expect some magic to happen that your compiler knows how to build that plugin from an empty directory?

    The psql-folder was just created by me.
    You shouldn't be creating any directories. Qt sources should contain a psql directory inside src/plugins/imageformats and there should be a bunch of files there including a README file containing requirements and instructions for building the plugin.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Qt project management - bigger project
    By Peppy in forum Qt Programming
    Replies: 11
    Last Post: 24th December 2010, 13:50
  2. How to add a gif to a Qt Project?
    By Bong.Da.City in forum Newbie
    Replies: 5
    Last Post: 6th September 2010, 21:51
  3. new project
    By rk0747 in forum Qt Programming
    Replies: 5
    Last Post: 17th February 2010, 08:53
  4. Replies: 1
    Last Post: 3rd December 2009, 23:34
  5. Project generation on linux from QT Project
    By darpan in forum Qt Programming
    Replies: 6
    Last Post: 11th December 2006, 09:43

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.