Results 1 to 20 of 20

Thread: Want a static database plugin - tried a lot but have still DLL dependecies.

  1. #1
    Join Date
    Feb 2007
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Want a static database plugin - tried a lot but have still DLL dependecies.

    Hi,

    I want to distribute one executable file of my application which should be able to connect to a PostgreSQL database. After I did spend hours on compiling a static version of Qt I hoped that I can get one executables which has no external dependencies on any DLL.

    So that's what I did so far:

    1. As descripted in this article I changed the VS environmet to be able to create static Qt.

    2.
    configure -static -platform win32-msvc.net -qt-sql-psql -I C:\Programme\PostgreSQL\8.1\include -L C:\Programme\PostgreSQL\8.1\lib\ms
    After that I did run
    nmake sub-src
    I thought that the nmake process will create a static version of the qsql plugin!!

    3. I changed the main function of my project and added the following lines:
    Qt Code:
    1. #include <QtPlugin>
    2.  
    3. Q_IMPORT_PLUGIN(qsqlpsql)
    To copy to clipboard, switch view to plain text mode 

    The tool compiled succesfull without any errors. After that I checked the dependencies of my new executable and saw that it refers to the LIBPQ.DLL which, of course, refers to some other DLLs, too.

    Is there anything I have to change for a static version of my tool. I do not want these dependencies to the libpq.dll.

    Any suggestions.

    Thanks in advance.
    --Heisp
    Last edited by jacek; 22nd February 2007 at 19:07. Reason: changed [code] to [quote]

  2. #2
    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: Want a static database plugin - tried a lot but have still DLL dependecies.

    You have to compile/download a static version of the postgresql client library (libpq.dll) and probably all its dependencies as well (and then recompile the postgresql plugin in static mode)... Just for the record - it doesn't have anything to do with Qt itself

  3. #3
    Join Date
    Feb 2007
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Want a static database plugin - tried a lot but have still DLL dependecies.

    Hi,

    but I thought that this is what I did since I started configure with the -static option.
    I have libpq.lib as external lib defined in VS so it binds against the static lib, right?
    So why is there a need for the postgres DLLs?

    Could you please provide a step by step instruction?

    Thanks in advance,
    --Heisp

  4. #4
    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: Want a static database plugin - tried a lot but have still DLL dependecies.

    Quote Originally Posted by Heisp View Post
    but I thought that this is what I did since I started configure with the -static option.
    You only asked to compile Qt statically using available libraries. And the only pq lib available is the one compiled in shared mode.
    [quote\I have libpq.lib as external lib defined in VS so it binds against the static lib, right?[/quote]
    A static lib of what?
    So why is there a need for the postgres DLLs?
    Do you have a static postgres library?

    Could you please provide a step by step instruction?
    First try downloading a static libpq from the Internet. Othewise you'd have to recompile postgres.

  5. The following user says thank you to wysota for this useful post:

    Heisp (22nd February 2007)

  6. #5
    Join Date
    Feb 2007
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Want a static database plugin - tried a lot but have still DLL dependecies.

    Hi,

    thank you for that hint. It's working now and my app is static.

    Great - that's what I want.

    Thanks again.
    --Heisp

  7. #6
    Join Date
    Sep 2007
    Posts
    31
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Exclamation Re: Want a static database plugin - tried a lot but have still DLL dependecies.

    I have similar problem with mingw32.

    1. I've configured and made qt statically:

    Qt Code:
    1. @echo off
    2.  
    3. set LIB=
    4. set INCLUDE=
    5. set QTDIR=C:\Qt\4.3.1
    6. set PATH=C:\Qt\4.3.1\bin
    7. set PATH=%PATH%;C:\MinGW\bin
    8. set PATH=%PATH%;%SystemRoot%\System32
    9. set QMAKESPEC=win32-g++
    10. set PGDIR=C:\Progra~1\PostgreSQL\8.2
    11.  
    12. cd %QTDIR%
    13. REM make confclean
    14. pause
    15. configure -release -static -no-qt3support -no-rtti -no-stl -no-exceptions -no-accessibility -qt-libpng -qt-sql-psql -I %PGDIR%\include -L %PGDIR%\lib -l libpq
    16. REM cd %QTDIR%\src
    17. REM qmake
    18. mingw32-make release
    To copy to clipboard, switch view to plain text mode 

    2. After succesfull compilation (like given below):

    Qt Code:
    1. g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-s -Wl,-subsystem,windows -o "release\sigs_tk.exe" object_script.sigs_tk.Release -L"c:\Qt\4.3.1\lib" -lmingw32 -lqtmain -lversion -lQtSql -lQtGui -lQtCore -lgdi32 -lcomdlg32 -loleaut32 -limm32 -lwinmm -lwinspool -lmsimg32 -lQtCore4 -lkernel32 -luser32 -lshell32 -luuid -lole32 -ladvapi32 -lws2_32 -L"C:\Progra~1\PostgreSQL\8.2\lib" -lpq
    To copy to clipboard, switch view to plain text mode 

    I still have "LIBPQ.DLL" in dependencies.

    Where is my missing?

    Note: libpq.a file in C:\Progra~1\PostgreSQL\8.2\lib dir is 96 kb.

  8. #7
    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: Want a static database plugin - tried a lot but have still DLL dependecies.

    Delete or rename the libpq.dll for the time of compilation so that the dll doesn't come before the static version of the library.

  9. #8
    Join Date
    Sep 2007
    Posts
    31
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: Want a static database plugin - tried a lot but have still DLL dependecies.

    renamed all libpq.dll after full search on all drives - still the same. + libpq.a placed to "lib folder of Qt - the same. Now in dependencies "LIBPQ" marked with "?" sign (means - can't be found in any location).

    So, may my "libpq.a" be just a wrapper for libpq.dll? If so - how can I get real, static libpq.a? Second variant of libpq.a - built from sources (first was found in lib folder after win32-installer). Second variant gives the same result.
    Last edited by brokensword; 17th September 2007 at 09:03.

  10. #9
    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: Want a static database plugin - tried a lot but have still DLL dependecies.

    Well, obviously you need a static library for PostgreSQL installed. You should probably visit www.postgresql.org and search for info on obtaining a static client library there. 96kB for libpq doesn't seem correct.

  11. #10
    Join Date
    Sep 2007
    Posts
    31
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Want a static database plugin - tried a lot but have still DLL dependecies.

    In documentation regarding Win32 (http://www.postgresql.org/docs/8.2/i...all-win32.html) there are remarked that after building we will have following binaries:

    interfaces\libpq\Release\libpq.dll
    The dynamically linkable frontend library

    interfaces\libpq\Release\libpqdll.lib
    Import library to link your programs to libpq.dll

    interfaces\libpq\Release\libpq.lib
    Static version of the frontend library

    And I really got them (libpq.lib - 323Kb, pibpq.dll - 104Kb, libpqdll.lib - 26,6Kb)

    There is nothing remarked about MinGW installation. But after building with MingW I have got libpq.dll (size 149Kb) and libpq.a (size 96Kb).

    There should be some undocumented way of how to get real static libpq.a using MinGW...

  12. #11
    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: Want a static database plugin - tried a lot but have still DLL dependecies.

    Try forcing a link to libpq.a by adding it to the LIBS variable like so:

    LIBS+= /path/to/libpq.a (without "-l" at the beginning)

  13. #12
    Join Date
    Sep 2007
    Posts
    31
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Want a static database plugin - tried a lot but have still DLL dependecies.

    LIBS+= /path/to/libpq.a (without "-l" at the beginning)
    I've copied libpq.a to C:\mingw\lib. Your slution produces:

    Qt Code:
    1. g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-s -Wl,-subsystem,windows -o "release\sigs_tk.exe" object_script.sigs_tk.Release -L"c:\Qt\4.3.1\lib" -lmingw32 -lqtmain C:\mingw\lib\libpq.a -lversion -lQtSql -lQtGui -lQtCore -lgdi32 -lcomdlg32 -loleaut32 -limm32 -lwinmm -lwinspool -lmsimg32 -lQtCore4 -lkernel32 -luser32 -lshell32 -luuid -lole32 -ladvapi32 -lws2_32
    To copy to clipboard, switch view to plain text mode 

    and fails with lot of errors:

    Qt Code:
    1. c:\Qt\4.3.1\lib/libQtSql.a(qsql_psql.o)(.text+0x19):qsql_psql.cpp: undefined reference to `PQerrorMessage'
    2. c:\Qt\4.3.1\lib/libQtSql.a(qsql_psql.o)(.text+0x18c):qsql_psql.cpp: undefined reference to `PQresultStatus'
    3. c:\Qt\4.3.1\lib/libQtSql.a(qsql_psql.o)(.text+0x28f):qsql_psql.cpp: undefined reference to `PQntuples'
    4. c:\Qt\4.3.1\lib/libQtSql.a(qsql_psql.o)(.text+0x494):qsql_psql.cpp: undefined reference to `PQclear'
    5. c:\Qt\4.3.1\lib/libQtSql.a(qsql_psql.o)(.text+0x5e4):qsql_psql.cpp: undefined reference to `PQntuples'
    6. c:\Qt\4.3.1\lib/libQtSql.a(qsql_psql.o)(.text+0x622):qsql_psql.cpp: undefined reference to `PQnfields'
    7. c:\Qt\4.3.1\lib/libQtSql.a(qsql_psql.o)(.text+0x67e):qsql_psql.cpp: undefined reference to `PQftype'
    To copy to clipboard, switch view to plain text mode 

    Inserting "-LIBS+= C:\mingw\lib\libpq.a" directly to makefile fails with same errors.

  14. #13
    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: Want a static database plugin - tried a lot but have still DLL dependecies.

    Are you sure the .a file is actually the library you're looking for?

  15. #14
    Join Date
    Sep 2007
    Posts
    31
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Want a static database plugin - tried a lot but have still DLL dependecies.

    I hope - yes. I don't see any other variants

  16. #15
    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: Want a static database plugin - tried a lot but have still DLL dependecies.

    Hope is not what I expected. Could you verify that?

  17. #16
    Join Date
    Sep 2007
    Posts
    31
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: Want a static database plugin - tried a lot but have still DLL dependecies.

    how can I verify it? All pages I've found in internet so far say that libpq.a file is an analog of libpq.lib file. First is for gcc compilation, while second is for VS. There are no other possible libraries. On hundred forums in internet peoples compiling applications with just -lpq parameter and everything works. It really works, but depends on libpq.dll file and cannot be launched without it (noone remarks it in posts btw).

    What have I found so far: libpq.a "pseudo-static" library is needed by QtSql module. Without libpq compilation finishes on QtSql linking stage. So, libpq is needed by QtSql only.

    One interesting experimental fact - when linking QtSql4 (instead of QtSql) without specifing libpq -compilation finishes without errors! But after launching compiled application "PQSQL driver not found" errors appear.

  18. #17
    Join Date
    Sep 2007
    Posts
    31
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Exclamation Re: Want a static database plugin - tried a lot but have still DLL dependecies.

    Problem solved. To build real static libpq.a you need specify undocumented key "enable_shared=no". It's ~1.5 times bigger (156Kb) then "pseudo-static" libpq.a (97Kb)

  19. #18
    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: Want a static database plugin - tried a lot but have still DLL dependecies.

    So that was just an import library after all.

  20. #19
    Join Date
    Sep 2007
    Posts
    31
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Exclamation Re: Want a static database plugin - tried a lot but have still DLL dependecies.

    btw, the bug (or feature?) of libpq.a building still exists (that's why my problem occured). Maybe it can be useful for someone.

    Here is description. You will never get real static libpq.a if you have done building of shared version of libpq before. You MUST delete pseudo-static libpq.a before building real static libpq.a

    Folder "\src\interfaces\libpq\":
    Here is failure scenario:
    1. make install (dynamic libpq.dll and pseudo-static libpq.a were created)
    2. make install enable_shared=no (get real static libpq.a - fails).
    Real static libpq.a wasn't created. Insted of it we can see old, pseudo-static libpq.a.

    Another failure scenario:
    1. make install enable_shared=no (real static libpq.a was created - indeed).
    2. make install (dynamic libpq.dll and pseudo-static libpq.a were created).
    Real static libpq.a was overwritten by pseudo-static libpq.a!

    Here is successfull, working scenario:
    1. make install (dynamic libpq.dll and pseudo-static libpq.a were created).
    2. delete pseudo-static libpq.a.
    3. make install enable_shared=no (get real static libpq.a).
    So that's only possible way to get both shared and real static libpq libraries.

    Strange, why pseudo-static libp.q can overwrite real static one but can't vice-versa?

    I think lot of bugs peoples have with libpq are based on that bug...

  21. #20
    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: Want a static database plugin - tried a lot but have still DLL dependecies.

    It's neither a bug nor a feature. It's just the way make works. Basically if you change configuration options you should always issue "make clean" afterwards (or "before" in that case).

Similar Threads

  1. Threads and database connection
    By probine in forum Qt Programming
    Replies: 9
    Last Post: 7th August 2013, 08:30
  2. Replies: 16
    Last Post: 23rd May 2008, 10:12
  3. plugin loading problem
    By naresh in forum Qt Programming
    Replies: 6
    Last Post: 9th June 2007, 19:05
  4. Filling combobox from database
    By Philip_Anselmo in forum Qt Programming
    Replies: 3
    Last Post: 11th May 2006, 17:53

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.