Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Clarification of "/path/to/Qt" in Qt documentation



  • I'm working through the instructions on the following page to create a statically-linked version of my application to deploy:

    https://doc.qt.io/archives/qt-4.8/deployment-x11.html

    The first step in the instructions is to create a statically-linked version of Qt:

    cd /path/to/Qt
    ./configure -static -prefix /path/to/Qt <other parameters>
    make sub-src
    

    I have Qt installed in ~/Qt (aka, /home/inplant/Qt). I tried:

    cd ~/Qt
    ./configure -static -prefix ~/Qt
    

    but, the configure program is not there.

    I inferred from the instructions that /path/to/Qt must be a folder that includes "configure" since the instructions indicate to run "./configure ...." So, I used the find command to search for "configure" and found the most likely candidate to be: ~/Qt/5.12.1/Src/qtbase. So, I ran:

    cd ~/Qt/5.12.1/Src/qtbase
    ./configure -static -prefix ~/Qt/5.12.1/Src/qtbase
    make sub-src
    
    

    It ran for a long time and it looked like it succeeded. I followed the rest of the instructions on the page. But, it didn't seem to create a statically linked version of my application (based on the test at the bottom of the instructions.)

    My questions is pretty simple. Is "/path/to/Qt" really supposed to be in the Src/qtbase directory? Is there some other location?


  • Moderators

    First: don't use Qt 4 documentation to build Qt 5. It's horribly outdated, many flags have changed!

    Now, the paths. The path you add to -prefix flag means "where Qt will be installed". That means it should be an empty directory! (it does not have to be, but it is best if it is)

    The configure you should run is in root of your Qt source dir. So when you unpack the Qt tarball, just cd inside and there is your configure. Using the other one in qtbase is also possible, but a bit more advanced and in general discouraged.

    Lastly, here is what I recommend from personal experience:

    1. Unpack Qt to some directory, let's say ~/qt-5124-src.
    2. Create a new build directory, for example ~/qt-5124-build.
    3. Create a new installation dir, for example ~/qt-5124.
    4. Cd into your build dir and run configure like this: ../qt-5124-src/configure -static -prefix ~/qt-5124.
    5. Run make -j X. where X is the number of cores your CPU has.
    6. Run make install.

    This approach has several advantages:

    • after successful compilation you can completely remove directories 1. and 2. (src and build) - they are not necessary for Qt to work!
    • all your build files are in ~/qt-5124-build, so if your compilation fails, or you pick wrong flags etc. - all you need to do is to remove that directory, create it again and run steps 4., 5. and 6. again. Your source dir is never "polluted" with any build artifacts
    • your installation dir will contain only final, compiled stuff that is necessary to use Qt. It will be quite small in size compared to build and src dirs == you save space


  • Oh, good catch on the version-I missed that altogether. I have a VM snapshot and will revert and do as you suggested. Thanks!


Log in to reply