Nominate our 2022 Qt Champions!

Two problems on sql support while compiling static lib of Qt,could anyone help me?

  • Hey!

    Thanks to read my topic,I'm a newbee on Qt and I've been puzzled for almost ONE week with my problems.

    I want to build a static-linking Qt library of Qt 5.3.2 on windows 7(64bits),and I've downloaded the source package and extracted all contents into a directory,and,here is problem one:

    I configured Qt with "-qt-sql-sqlite"option.When compiling it,I got a fatal error message which said somethings like "...ld.exe : -lqsqlite ... can't find library..." blablabla...

    I'm very sorry for my forgotting on message details,because I've started a new trying of compiling.

    I'm very surprise about that error because SQLite v3 has been included in Qt(refered in "Qt SQL->SQL Programming->SQL Database Drivers->How to Build the QSQLITE Plugin), and , how to solve it? and... by the way, does it mean that only plugin of SQLite can be built with Qt?

    Problem two:

    I'v tried another configuration option which is "-plugin-sql-qsql", but when I complining Qt I got the error message like this:
    ......\sql\drivers\psql\qsql_psql.cpp:59:22: fatal error: libpq-fe.h: No such file or directory
    #include <libpq-fe.h>

    I'v searched all the source directory and could not find the header file named "libpq-fe.h".With the searching result of this problem on webs I generally understood that was because I didn't install PostgreSQL's dev-libs.

    Well, the questions come:

    Does all the SQL diver of databases which supported by Qt require their dev-libs or codes while compiling Qt?

    Because the binary package of Qt contains the binary SQL drivers of all supported databases,could I skip the compiling of SQL drivers while compiling Qt? If it is possible,how to do it?

    Thanks again for reading this tediously long topic, and please help me!

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    1. Yes except sqlite since it's provided in source. However you can also use your system's sqlite if you want to. You don't need to have every dev-libs installed. only the ones you want to support and build right away.

    2. IIRC, you would have to build a Qt version at least of the same revision or higher to use plugins from an older version (you have to keep the major version matching) Unless you have the dev package installed in your system. The configuration script won't find the so it won't try to build them.

    As for your linking error, I must say it's pretty strange. Did you build your static version from a clean tree ?

  • Thanks for replying!

    I'm very sure that I was building it from a clean tree,because every time I failed I deleted the whole directory of source code and re-extract it from the achieve which is downloaded from : .

    But,I'm not sure about whether I had installed all the tools required by building(such as Python,Ruby,etc...),I will try it again later and report my result.

    Well,there is a question still waiting for answer:

    • Because the binary package of Qt contains the binary SQL drivers of all supported databases,could I skip the compiling of SQL drivers while compiling Qt? If it is possible,how to do it?

    Could you tell me about that? thanks!

  • Lifetime Qt Champion

    It's in my answer 2) :)

  • Hi,
    I'm sorry that I'm so late.

    For the question I asked again,I had read the chapter in Qt Docs again which described the information about SQL driver,with your explanation,I think I had roughly understood it.Thanks!

    For the link error that I met,I'v tried to rebuild Qt 5.3.2 with option -qt-sql-sqlite,and this time I'm actually confirmed that all the tools needed by the building had been installed on my system.But the link error still remains,the message is:
    ...ld.exe: cannot find -lqsqlite

    But it was so pitty that I had no time to search all the compiling directory to confirm whether the file 'qsqlite.*' existed.

    I guess maybe it is a configuration bug in Qt 5.3.2 package.What do you think about it?

  • Lifetime Qt Champion

    What options did you pass exactly to configure ?
    Did you build the static version from scratch ?

  • Well,the command I typed to configure Qt is :
    configure -platform win32-g++ -static -release -qt-sql-sqlite -qt-zlib -qt-libpnf -qt-libjpeg -nomake examples -no-compile-examples
    The source code is packed in the install package which is downloaded from :
    I have tried with the absolute source package downloaded from : ,and it took the same error.

  • Lifetime Qt Champion

    Strange, just tested on OS X and it built find without requesting qsqlite since it's built in

  • The link error is reported at a project named 'calendar',which is located at 'src/qtbase/examples/widgets/richtext' or 'src/qtquickcontrols/examples/quick/controls'.But I'm not sure which one is.

    By the way,I built it on Windows 7 64bit home edition,But I don't think this is the major reason of link error.

    reply to SGaist(I can’t reply the post by clicking reply button on this forum,so I can only reply you on this way,sorry! and I hate this weak forum!):

    I tried to not building the examples by passing "-nomake examples -no-compile-examples" to configure program for time-saving purpose. But I don't know why the example is still be compiled. And the compiling failure on example means something wrong in compiled package.I don't know why.

    Now I'm using Qt 5.4,and compiled the static libraries under MSYS in windows 7 successfully. So I guess the problem is raised with no MSYS. In other words, I think the compiling of Qt needs some tools that windows can not provide. But unfortunately, I can't find which tool it require!

  • Lifetime Qt Champion

    Do you mean you are building the examples while building Qt or after that ?

Log in to reply