Search code examples
qtqmakestatic-linking

Error while creating qmake for a Qt static build


I got stuck trying to build Qt libraries statically with this command:

/strg/Qt/qt-everywhere-src-5.10.0 $ ./configure -static -prefix /strg/Qt

and getting this response:

+ cd qtbase
+ /strg/Qt/qt-everywhere-src-5.10.0/qtbase/configure -top-level -static -prefix /strg/Qt
./configure: 49: exec: /strg/Qt/qt-everywhere-src-5.10.0/qtbase/configure: not found

I attempted to resolve this using vim command set userformat=unix on the file qtbase/configure.

After running the same line /strg/Qt/qt-everywhere-src-5.10.0 $ ./configure -static -prefix /strg/Qt things are no better:

Creating qmake...
’
make: *** [main.o] Error 1
.

I am following the instructions on http://doc.qt.io/qt-5/linux-deployment.html and I guess, I could make a mistake during the previous steps. Could you help me?


Solution

  • Ok, your sources are in /strg/Qt/qt-everywhere-src-5.10.0. I prefer having separate build and install dirs:

    Create build dir, e.g. /strg/Qt/build and create install dir, e.g. /strg/Qt/install

    Go to build dir:

    cd /strg/Qt/build
    

    Run configure from your build dir and give install dir using -prefix:

    ../qt-everywhere-src-5.10.0/configure -static -prefix /strg/Qt/install
    

    Other useful configure parameters you might use (don't skip qtwebengine if you need it, if you don't need it you save lots of time by skipping it)

    ../qt-everywhere-src-5.10.0/configure -opensource -confirm-license -static -release -prefix /strg/Qt/install -make libs -nomake tools -nomake examples -nomake tests -skip qtwebengine