Page 2 of 2 FirstFirst 12
Results 21 to 38 of 38

Thread: How to add a lib to a qt project

  1. #21
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 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.


  2. #22
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,670
    Thanks
    13
    Thanked 1,595 Times in 1,523 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 

  3. #23
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,391
    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.

  4. #24
    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

  5. #25
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 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.


  6. #26
    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.

  7. #27
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 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.


  8. #28
    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 expected no kind of magic. But as you know that thread is posted in -Newbie- Forum. It's my first qt project and noone tells you what qmake and nmake are supposed to do. So I could be that qmake creates the psql.pro...

    Anyway, now I know that it works in a different way.
    I think my problem was I had installed the "qt sdk 2010.05" and the "qt 4.7.2". And in one folder the folder "...\qt\src\plugins\sqldrivers\psql" exists and in one not.

    Now I've found the psql-project and the qmake-command seems to work.

    But when I use mingw32-make.exe I get errors again.
    C:/qt/2010.05/mingw/bin/mingw32-make -f Makefile.Debug all
    mingw32-make[1]: Entering directory 'C:/Qt/2010.05/qt/src/plugins/sqldrivers/psql'
    g++ -c -g -frtti -fexeptions -mthreads - Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_DLL -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I "..\..\..\..\include\QtCore" -I"..\..\..\..\include\QtSql" -I"..\..\..\..\include" -I"c:\psql9\include" -I"..\..\..\..\include\ActiveQt" -I"tmp\moc\debug_shared" -I"..\..\..\..\mkspecs\win32-g++" -o tmp\obj\debug_shared\main.o main.cpp
    Der Befehl "g++" ist entweder falsch geschrieben oder konnte nicht gefunden werden
    mingw32-make[1]: *** [tmp/obj/debug_shared/main.o] Error 1
    mingw32-make[1]: Leaving directory 'C:/Qt/2010.05/qt/src/plugins/sqldrivers/psql'
    mingw32-make: *** [debug-all] Error 2
    The German expression in the cmd-output means:
    The command "g++" is wrong spelled or does not exist
    I haven't chosen something with g++.
    Please help me again.

  9. #29
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 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 expected no kind of magic. But as you know that thread is posted in -Newbie- Forum.
    If you look at the description of the forum you'll notice it says "Newbie to Qt", not "Newbie to programming".

    It's my first qt project and noone tells you what qmake and nmake are supposed to do.
    The docs for Qt and Visual Studio should tell you that. You can't expect to have zero knowledge about something and immediately use it to its full potential. Maybe your first Qt project should be something simpler than accessing databases.

    But when I use mingw32-make.exe I get errors again.


    The German expression in the cmd-output means:


    I haven't chosen something with g++.
    Please help me again.
    Please learn to use a compiler.
    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.


  10. #30
    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

    That's not my first programming project at all.
    Your post was not that helpful.
    I don't know why you are going to do verbal attacks against me.

  11. #31
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 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'm not doing any verbal attacks against you. I'm just irritated with "I'm a newbie, be nice and fuzzy and do everything for me" attitude. If you use a tool, any tool, learn what it does before you use it for the first time. Otherwise one day you might be unpleasantly suprised when some tool destroys something important for you.

    One of the first sentences in qmake docs says:
    qmake generates a Makefile based on the information in a project file.
    This gives you the following information:
    1. qmake is a tool
    2. it needs a project file
    3. it generates something called a "Makefile"

    And then there is two sentences that you have written:
    It's my first qt project and noone tells you what qmake and nmake are supposed to do. So I could be that qmake creates the psql.pro...
    One sentence from the docs can tell you so many things noone had told you before. Maybe it's time to get a bit more familiar with manuals? It's really nothing personal, I have nothing against you just please don't excuse yourself by saying that nobody told you what some tool did.
    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.


  12. #32
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,670
    Thanks
    13
    Thanked 1,595 Times in 1,523 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

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

    Quote Originally Posted by WilliamSpiderWeb View Post
    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.
    Here it is blow by blow:
    • Open your Windows Start menu
    • Locate the "Qt SDK by Nokia (2010.05)" folder
    • Open it and select "Qt Command Prompt"
    • In the new command prompt everything is correctly set to find the Qt SDK tools (like qmake and mingw32-make). Test by issuing a "qmake -v" command. You should get a Qmake and Qt version number. If you don't get the version message then stop, you won't get any further.
    • Locate the Qt source code in the installed Qt SDK. The default location would be something like "C:\qt\2010.05\qt\src" but you will have to use your knowledge of your system to find it. If you cannot find the sources then stop, you won't get any further.
    • In the command prompt change directory to the psql driver directory in the Qt source. The command prompt environment has a variable that points to the Qt directory, QTDIR, so this is the quickest way to get there:
      Qt Code:
      1. CD %QTDIR%
      2. CD src\plugins\sqldrivers\psql
      3. qmake "INCLUDEPATH+=C:\pgsql\include" "LIBS+=C:\pgsql\lib\libpq.lib" psql.pro
      4. mingw32-make
      To copy to clipboard, switch view to plain text mode 

  13. #33
    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

    Hey Chris,
    thanks for helping me again.

    I followed your detailed instructions.
    The differences to my last try is, this time I used "Qt command prompt". Last time it was "Windows command prompt". And there was a blank in the installation path of postgresql. I elliminated the blank for plugin building now.

    There were no error messages while building the plugin now.

    But I haven't understood what to do now to use the plugin.

  14. #34
    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

    Okay,
    Here in Qt Centre I found this wiki article:
    http://www.qtcentre.org/wiki/index.p...ws_using_MinGW

    When I compare what I've done with this article, I find the files "qsqlpsql4.dll" and "qsqlpsqld4.dll" in the folder "%QTDIR%\plugins\sqldrivers".

    If I load the "qsqlpsql4.dll" with the dependency walker I get the information that there are a few files missing (libpq.dll, mingwm10.dll, libgcc_s_dw2-1.dll, qtcore4.dll, qtsql4.dll).

    Tomorrow I'll try to update my enviromental variable paths.
    Please tell me if I'm completly wrong.

    Greetings

  15. #35
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 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

    Lot to learn you still have, young padawan. However on the right path you are.
    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.


  16. #36
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,670
    Thanks
    13
    Thanked 1,595 Times in 1,523 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

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

    Quote Originally Posted by WilliamSpiderWeb View Post
    Okay,
    If I load the "qsqlpsql4.dll" with the dependency walker I get the information that there are a few files missing (libpq.dll, mingwm10.dll, libgcc_s_dw2-1.dll, qtcore4.dll, qtsql4.dll).
    When you started Dependency Walker it was given the default Windows environment PATH, which does not include the Qt bin directories that contain all of the Qt and MingW files listed there. The default environment PATH also does not contain the PostgreSQL binary directory for the PostgreSQL library. Consequently, the Dependency Walker could not load any of these DLLs. If you had launched the Dependency Walker from the "Qt Command Prompt" most of the libraries, except the Postgres ones, would have been found.

    You should add the PostgreSQL bin directory to your system PATH. If you develop your program in an environment with the Qt paths set properly such as the Qt Command Prompt or Qt Creator then you should not need to add QT or MingW stuff to the system path. When you deploy you will need to ship the MingW, PostgreSQL and Qt libraries with your application.

  17. #37
    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

    Now I added the following paths to the enviroment variable path
    C:\psql9\bin
    C:\qt\2010.05\bin
    C:\qt\2010.05\qt\bin
    C:\qt\2010.05\mingw\bin
    But then there are more and more dlls the dependency walker cannot found or with other errors
    Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module.
    Error: Modules with different CPU types were found.

  18. #38
    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

    Just to inform other Newbies who want to connect to PostgreSQL databases as well...

    My last-ditch attempt was, just don't care about what the results of the dependency walker are and copied ALL dlls of %postgresdir%\bin.

    Now I can load the QPSQL Driver and connect to my postgresql database.

    At this point I want to thank the experts of this forum again for trying to help me.


    Greetz, wsw
    Last edited by WilliamSpiderWeb; 19th March 2011 at 01:09.

Similar Threads

  1. Qt project management - bigger project
    By Peppy in forum Qt Programming
    Replies: 11
    Last Post: 24th December 2010, 14: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, 22:51
  3. new project
    By rk0747 in forum Qt Programming
    Replies: 5
    Last Post: 17th February 2010, 09:53
  4. Replies: 1
    Last Post: 4th December 2009, 00:34
  5. Project generation on linux from QT Project
    By darpan in forum Qt Programming
    Replies: 6
    Last Post: 11th December 2006, 10: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.