Static compilation of Qt from source code

System: Debian 8. So, I need to build Qt Creator statically. What I do:

  1. Installing the necessary dependencies

    $ sudo apt-get install build-essential ^libxcb.* libx11-xcb-dev libglu1-mesa-dev libxrender-dev libfontconfig1-dev
    
  2. I download and unpack the source code

    $ wget https://github.com/qt/qt/archive/4.8.zip + распаковка
    
  3. Unpacked in /home/user_name/. I go there using cd

  4. Configuring with the static build option

    $ ./configure -platform linux-g++ -release -static -fontconfig -opensource -confirm-license
    
  5. Collecting

    $ make
    
  6. And installing

    $ sudo make install
    

If I understand everything correctly, then the system should install Qt Creator statically, i.e. I can collect my projects as a single file. However, there is no qt in the lists of all programs (dpgk). How do I start it? Or am I just doing something wrong or not understanding something? The compiled files are located here:

/usr/local/Trolltech/Qt-4.8.7/

Tell me how to correctly build QT from the source code (necessarily statically, so that I can finally sew all the used libraries into executable file) and most importantly-run?

Author: gil9red, 2018-07-13

1 answers

So, I answer my own question, because no one helped and I had to figure it out. For static compilation of QT, you need the following: Install Qt Creator. View the version of the Qt you are using in about. Sometimes, additional dependencies are needed for the build. Install it if necessary:

sudo apt-get install build-essential ^libxcb.* libx11-xcb-dev libglu1-mesa-dev libxrender-dev libfontconfig1-dev

Then go here, select the desired version and download the archive with the source files in the single folder:

qt-everywhere-src-"ВЕРСИЯ".tar.xz

The next step is to download the source code, by any means, and unpacking to a specific folder(for example):

/home/USER-NAME/qt_source/

After unpacking is complete, create a folder in the output directory of the compiled Qt:

mkdir -p /usr/lib/Qt5_st

Go to the unpacking directory:

cd  /home/USER-NAME/qt_source/

Next, run the build configurator:

./configure -platform linux-g++ -release -static -fontconfig -opensource -confirm-license -nomake examples -nomake tests -qt-zlib -qt-libpng -qt-libjpeg -prefix /usr/lib/Qt5_st

, where-static is what it was all about. Static build of projects. The rest can be found in the documentation.

And then run the build commands and then install Qt in the system:

sudo make
sudo make install

We are waiting for a certain amount of time, it all depends on the configuration of the PC where the compilation takes place.

After compilation, the created folder /usr/lib/Qt5_st/bin will contain a qmake file, to which you need to specify the path in QT itself (Tools-Parameters-QT Profiles-Add-and select the qmake file from the folder /usr/lib/Qt5_st/bin)

Next, click apply - go to the kits tab-click add, select the QT profile at the bottom of the list and select the one created on in the previous step, the profile. All that remains is to click apply and OK. You can close the settings, and add a profile to the current project. To do this, press CTRL + 5 and add a new build option to the project.

And that's all, when compiling the project, the output will be a single binary file that includes all the Qt libraries used.

 0
Author: Range, 2018-07-15 13:52:31