Page 1 of 2 12 LastLast
Results 1 to 20 of 24

Thread: PostgreSQL and Windows Community Version

  1. #1
    Join Date
    Jan 2006
    Posts
    40
    Thanks
    3
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default PostgreSQL and Windows Community Version

    Hi,

    I have been developing an Open Source program in Linux using psotgreSQL and the community version of QT. I am at a stage when I wish to test in in Windows, for that I require the psql plugin.

    The commands I used are as follows:

    Qt Code:
    1. qmake -o Makefile "INCLUDEPATH+=C:\psql\include" "LIBS+=C:\psql\lib\ms\libpq.lib" psql.pro
    2. make
    To copy to clipboard, switch view to plain text mode 

    This generated .a and .dll files in the C:\Qt\4.1.1\plugins\sqldrivers directory.

    However when I run my program I am unable to load the drivers.

    I had also tried to generate the dlls using the configue approach suggesting in an earlier post, again the files were created but I was unable to load the drivers.

    Using the File Monitor program (as suggested in an earlier thread) my program is reading this dll. I ask my program to display the available drivers, so I can see it access qsqlite, qsqlodbc and qsqlpsql, teh request and results appear to match in all cases, but the result is that I stil fail to have access to the psql driver from withn my program, so sad.

    Does anyone have any suggestion on what else to try?

    Many thanks for you time,

    graeme.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PostgreSQL and Windows Community Version

    Use Dependency Walker to check if you have all DLLs required by the PostgreSQL driver.

  3. #3
    Join Date
    Jan 2006
    Posts
    40
    Thanks
    3
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PostgreSQL and Windows Community Version

    Hi,

    I tried that. I profiled my app and got the dialog box that I put in to dispaly the number of drivers. I then tried to connect (even though the psql driver is not listed) the connection obviously failed. I then closed the app.

    Looking at the output generated by Dependency Walker, it gave references to QTSQLD4.dll, but none of the driver specific dlls.

    It flagged a number of dlls in error:
    CCL30.DLL, EFSADU.DLL, MSJAVA.DLL and WINTAB32.DLL
    And some warning were generated:
    KERNEL32.DLL, MPR.DLL, MIDIMAP.DLL and MSCTFIME.DLL

    Any suggestions on where I should go next?

    cheers,

    graeme.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PostgreSQL and Windows Community Version

    Quote Originally Posted by graeme
    Looking at the output generated by Dependency Walker, it gave references to QTSQLD4.dll, but none of the driver specific dlls.
    Have you tried the Dependency Walker on your application or on the plugin?

    Quote Originally Posted by graeme
    It flagged a number of dlls in error:
    CCL30.DLL, EFSADU.DLL, MSJAVA.DLL and WINTAB32.DLL
    And some warning were generated:
    KERNEL32.DLL, MPR.DLL, MIDIMAP.DLL and MSCTFIME.DLL
    Don't worry about these DLLs.

    Quote Originally Posted by graeme
    Any suggestions on where I should go next?
    Do you have a debug version of the plugin? Did you try compiling your application in release mode?

  5. #5
    Join Date
    Jan 2006
    Posts
    40
    Thanks
    3
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PostgreSQL and Windows Community Version

    I ran Dependency Walker on the application, when I run it on the dll I get the following error:

    At least one required implicit or forward dependency was not found.

    This was for, I believe, LIBPQ.DLL, I do not get this error when I try the other plugins. So I guess this is teh problem, but I'm still unceratn where to go from here, although it does give me something to Google.

    The application was origianlly in debug mode, I now have it in release mode, but no difference.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PostgreSQL and Windows Community Version

    Quote Originally Posted by graeme
    This was for, I believe, LIBPQ.DLL, I do not get this error when I try the other plugins.
    It looks like it can't find the PostgreSQL client library. Find that file and copy it to the same directory where your executable is (you might need other DLLs too, so check it with Dependency Walker).

  7. #7
    Join Date
    Jan 2006
    Posts
    40
    Thanks
    3
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PostgreSQL and Windows Community Version

    Just done that and whilst Dependency Walker is now happy, my app refuses to play ball

    I have now put the driver along with the dlls in the plugin directory and in an sqldrivers directory in the same direcotiry as the executable but no joy.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PostgreSQL and Windows Community Version

    Quote Originally Posted by graeme
    I have now put the driver along with the dlls in the plugin directory and in an sqldrivers directory in the same direcotiry as the executable but no joy.
    Are you 100% sure that both the plugin and the application were built in the same mode (i.e. both in debug mode or both in release mode)?

  9. #9
    Join Date
    Jan 2006
    Posts
    40
    Thanks
    3
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PostgreSQL and Windows Community Version

    I have both versions of the plugin qsqlpsql.dll & qsqlpsqld.dll.
    I tried with a release version of my app, followed by a debug version. I currently have a debug version.
    The postgresql dll are (I believe) release versions (no *d.dll)

    Should I just revert to the release version of the app?

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PostgreSQL and Windows Community Version

    Quote Originally Posted by graeme
    Should I just revert to the release version of the app?
    No, since you have both versions of the plugin.

    What does exactly QSqlDatabase::drivers() return when you invoke it from your application? What parameters do you pass to QSqlDatabase::addDatabase()?

  11. #11
    Join Date
    Jan 2006
    Posts
    40
    Thanks
    3
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PostgreSQL and Windows Community Version

    drivers returns:

    QSQLITE
    QODBC3
    QODBC

    The code you requested is:
    Qt Code:
    1. // Get the connection, if it exists
    2. QSqlDatabase dbConn = QSqlDatabase::database(connName,false);
    3. // Check that the driver is available
    4. if (!QSqlDatabase::isDriverAvailable(connType))
    5. throw sqlE(dbConn, QObject::tr("The Database driver ")+ connType + QObject::tr("is not available"));
    To copy to clipboard, switch view to plain text mode 

    followed by:

    Qt Code:
    1. // Okay the connection doesn't exist so let's add it using the appropriate driver type
    2. dbConn = QSqlDatabase::addDatabase(connType,connName);
    To copy to clipboard, switch view to plain text mode 
    The result is "... The Database driver QPSQLis not available"
    Last edited by graeme; 17th April 2006 at 20:22.

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PostgreSQL and Windows Community Version

    This is weird. I've never had any problems with QPSQL driver on windows.

    Quote Originally Posted by graeme
    qmake -o Makefile "INCLUDEPATH+=C:\psql\include" "LIBS+=C:\psql\lib\ms\libpq.lib" psql.pro
    ...
    This generated .a and .dll files in the C:\Qt\4.1.1\plugins\sqldrivers directory.
    What compiler do you use? I guess you use MinGW, if you got an .a file, but then you shouldn't be able to use the libpq.lib file.

    Try:
    qmake -o Makefile "INCLUDEPATH+=C:\psql\include" "LIBS+=C:\psql\lib" psql.pro

  13. #13
    Join Date
    Jan 2006
    Posts
    40
    Thanks
    3
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PostgreSQL and Windows Community Version

    I'm using Mingw32

    The switch you suggest gives an error:

    C:\psql\lib: No such file

    following you line of thought (I believe) I tried

    qmake -o Makefile "INCLUDEPATH+=C:\psql\include" "LIBS+=C:\psql\lib\libpq.a" psql.pro

    that created the files but still nothing when I run the program

  14. #14
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PostgreSQL and Windows Community Version

    Quote Originally Posted by graeme
    following you line of thought (I believe) I tried
    qmake -o Makefile "INCLUDEPATH+=C:\psql\include" "LIBS+=C:\psql\lib\libpq.a" psql.pro
    Yes, or "LIBS+= -LC:\psql\lib\ -lpq".

    Quote Originally Posted by graeme
    that created the files but still nothing when I run the program
    I hope you have removed all copies of the old driver.

    I always configure Qt like this:
    configure -L C:\...\psql\lib -I C:\...\psql\include -plugin-sql-psql ...
    Which Qt version do you use exactly? In one of the older versions one had to remove some keys from the registry in case of problems with plugins. It was something around HKEY_CURRENT_USER\Software\Trolltech\OrganizationD efaults\Qt Plugin Cache...

  15. #15
    Join Date
    Jan 2006
    Posts
    40
    Thanks
    3
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PostgreSQL and Windows Community Version

    I'm using 4.1.1

    I removed the old drivers, in fact I renamed the old file ran my program - no drivers. Copied the qsqlited.dll into the sqldrivers folder of my app it found that driver. Removed it - no drivers.

    Then ran the make. It created a new sqldrivers directory with the new psql driver. I copied it into my program sqldrivers directory and deleted it from the qt directory. But alas...

    I'll look for the registry entry.

  16. #16
    Join Date
    Jan 2006
    Posts
    40
    Thanks
    3
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PostgreSQL and Windows Community Version

    The registry only has the default value

  17. #17
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PostgreSQL and Windows Community Version

    Quote Originally Posted by graeme
    I'm using 4.1.1
    ...
    I'll look for the registry entry.
    If there was a problem with loading the driver Qt marked such plugin as invalid in the registry and then just ignored it (even after the problem was fixed), but AFAIR this was Qt 4.0.0 or 4.0.1.

  18. #18
    Join Date
    Jan 2006
    Posts
    40
    Thanks
    3
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PostgreSQL and Windows Community Version

    Okay I'm running out of ideas.

    From all of this I believe that the problem lies with how the dll is being created. So would getting an MS compiler help? I guess that I could download their C++ compiler and try it out. Or would it be better to configue and rebuild Qt?

  19. #19
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PostgreSQL and Windows Community Version

    Quote Originally Posted by graeme
    Okay I'm running out of ideas.
    Unfortunately, me too. One more thing you could try is to add "CONFIG += console" to your .pro file and check if there are any warnings on the console.

    Quote Originally Posted by graeme
    So would getting an MS compiler help?
    The problem is that Open Source edition supports only MinGW.

    Quote Originally Posted by graeme
    Or would it be better to configue and rebuild Qt?
    You could try to compile the driver into Qt. This way if there is some problem with linking, it might be easier to find it.

  20. #20
    Join Date
    Jan 2006
    Posts
    40
    Thanks
    3
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PostgreSQL and Windows Community Version

    I'm downloading 4.1.2 How do I link psql into QT? Woudl taht be with the configure switch you gave earlier?

    Qt Code:
    1. configure -L C:\...\psql\lib -I C:\...\psql\include -plugin-sql-psql
    To copy to clipboard, switch view to plain text mode 

    or would it be (essentailly a modification of what I did on Linux):

    Qt Code:
    1. configure -qt-sql-psql -I C:/pgsql/include -L C:/pgsql/lib
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Qt and PostgreSQL : version not supported
    By xinevil in forum Qt Programming
    Replies: 1
    Last Post: 10th July 2008, 13:00

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.