Important: Please read the Qt Code of Conduct -

[answered] static build my first project

  • Howdy! I'm trying to statically build my first project, so that it can run on another Linux (Ubuntu) computer.

    So far, I've followed the instructions from the following sites:

    Here's what I've done:

    downloaded a new copy of the tar.gz source code from here:

    unpacked the tar file in a new directory on my computer

    configure it via: ./configure -prefix /opt/path/name -static -nomake examples -nomake tools -release

    make -j 3

    make install

    Open QtCreator -> Tools -> Options -> Build & Run

    clicked "Add...", and added the new qmake file from my new Static Qt directory

    hit "OK"

    The next step: tell my program to change the qmake version in my program's Build Settings. Seems I need to change the "PATH" variable in QtCreator -> Projects -> Build Environment.

    Here is my original (unchanged) path:
    I changed both the folders that say "/opt/Qt5.2.1/5.2.1/gcc_64/bin", because that was where the old qmake was.

    Now, when I Rebuild my project, it does not use the new qmake. Here's what my compile output says:
    13:49:24: Running steps for project testPlot2...
    13:49:24: Starting: "/usr/bin/make" clean
    rm -f moc_mainwindow.cpp moc_qcustomplot.cpp
    rm -f ui_mainwindow.h
    rm -f main.o mainwindow.o qcustomplot.o moc_mainwindow.o moc_qcustomplot.o
    rm -f *~ core *.core
    13:49:24: The process "/usr/bin/make" exited normally.
    13:49:24: Configuration unchanged, skipping qmake step.
    13:49:24: Starting: "/usr/bin/make"
    /opt/Qt5.2.1/5.2.1/gcc_64/bin/uic .....
    Why does it skip the qmake step? How do I force it to qmake, thereby creating a new Makefile with my new static Qt files?

  • Lifetime Qt Champion


    You need to add that new Qt version to Qt Creator, then make a kit with it and finally use that kit with your project

  • Awesome - that worked. Now my new executable is 16.5MB (previously it was 750kB) so that's a good sign.

    Unfortunately, I'm not all the way there yet. It seems I still have other dependencies with this new static build. Here is the error when I try to run on another computer:
    ./testQtStatic: error while loading shared libraries: cannot open shared object file: No such file or directory
    Weird thing is, I don't have this file on my original computer anywhere (not in the static Qt, or in my "regular" dynamic Qt). So - how can the executable work on my original computer without this file? Is the file somehow hidden?

    I found this thread, it seems to explain similar details, but not my issue. Maybe I'm missing something :)

  • Lifetime Qt Champion

    libxcb is a system library used for the xcb platform plugin, you'll need to have it installed on your other computer in order to run the application

  • Excellent. I forgot that I had done that on my original computer (I had copy-pasted the commands from a WikiHow page and didn't realize what it was doing).

    Now - I'm finally done with the errors. Here was the last hiccup:
    QFontDatabase: Cannot find font directory /opt/Qt5.2.1/static_5.2.1/lib/fonts - is Qt installed correctly?
    Aborted (core dumped)
    I've found some "information (your old thread)": which seems to say that it is necessary to "make install" the Static build.

    Since I did do the make install on my original computer, I knew this wasn't it.

    I came across "another thread (thread)": that states that this error goes away if you create the directory it wants. This works for me - seems to be a silly work-around, but I'm ok with that.

  • Lifetime Qt Champion

    Indeed, you must install every build unless you are doing a developer build

Log in to reply