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

Need help moving from Ubuntu 18.04 LTS to Ubuntu 20.04.2 LTSs



  • I have been developing a qt application on Ubuntu 18.04. The application uses widgets and Qt-3D.
    I recently bought a new computer and installed Ubuntu 20.02.4 LTS.
    I want to install QT on the new machine and move my application from 18.04 to the 20.04.2 machine.
    Can someone please advise me on the best way to proceed.
    Thanks


  • Moderators

    Thank you for posting your detailed steps. Everything you did from #1 to #6 sounds good.

    @C-Cubed said in Need help moving from Ubuntu 18.04 LTS to Ubuntu 20.04.2 LTSs:

    My next step is to try moving my project from 18.04 LTS to 20.04.2 LTS. Unfortunately Qt creator does not have an option for really importing a project.

    You shouldn't need to do anything special to import your project. Just copy your source code directory hierarchy from your original machine into your new machine (but don't copy the *.pro.user file, because this file contains configurations for your specific machine). Then, use Qt Creator to open your top-level *.pro file. Read and fix the error messages from top to bottom (if any).

    P.S. The better way is to use a version control system (such as Git) to store and manage your project. This helps you to track changes in your code over time, and protects you from coding mistakes. It also provides a simple way to load your project on a different machine.



  • @C-Cubed
    Unless you built Qt yourself before, why not just install from the distro? I think you get 5.12 IIRC. It was fine for me.



  • @JonB I tried installing from distro using synaptic. It installed but I couldn't get my projects from my 18.04 LTS into new version of Qt on 20.04.02 LTS distro.
    Also qt creator didn't have any of the sample apps.
    I'm going to try installing via installer on qt site.



  • @C-Cubed
    I don't know what "synaptic" is. I have always done all my Qt installs via apt get, as I do with everything else under Ubuntu, and it has been good. I had no trouble moving from 16.04 -> 18.04 -> 20.04, and things in between.

    I don't think I did anything outside of this. I'm not certain, but if you take stuff from the Qt site it won't be prebuilt for Ubuntu? I don't care about examples/docs as they are all available online if I wanted them.

    There are probably many hits if you Google for this. I came across https://stackoverflow.com/a/48147461/489865

    sudo apt-get install build-essential

    sudo apt-get install qtcreator

    sudo apt-get install qt5-default

    Read that post and the others there. I see there is a comment for 20.04. And a mention of how to address "QtCreator examples and API docs missing"

    Or at one point in the past from my notes it seems I used Ubuntu Software Center for Creator

    Ubuntu Software Centre, Developer Tools, IDEs:

    Qt Creator > Install.

    Qt Creator > Tools > Options > Help > Documentation > Add > /usr/share/qtcreator/doc/ choose qtcreator.qch

    Hope the above notes help you.


  • Moderators

    @JonB said in Need help moving from Ubuntu 18.04 LTS to Ubuntu 20.04.2 LTSs:

    I don't know what "synaptic" is.

    It's a GUI for apt :-) https://www.nongnu.org/synaptic/



  • Thanks for the suggestions. So here is what I've done so far with some success and the rational.
    If anyone has a better approach, please let me know. The thorny part is moving the Qt project from 18.04 LTS to 20.04.2 LTS.

    1. Using dd I restored my 20.04.2 LTS installation to to state prior to installing Qt creator with synaptic.
      Why? Because I'm developing using Qt 3D I need all the 3D components. Trying to figure out what these
      are was too confusing.
    2. Installed Qt and Qt creator from Qt web site using Qt installer.
      https://download.qt.io/official_releases/online_installers/
      Why? This installs qt and a host of examples including examples for Qt 3D.
      The example project files (pro) and (pri) provide good templates for generating a Qt 3D app.
    3. Tried to build and run the Planets-qml example.
      Why? Its a Qt 3D app. If I could successfully build it, I would know
      my Qt Creator installation was correct.
      Initially building it generated a number of errors relating to missing libraries and include files.
    4. Used "apt-file search" to find packages for missing libraries and includes.
    5. Used apt update, apt upgrade, apt install to install missing libraries
    6. Successfully built and ran Planets-qml example.
      My next step is to try moving my project from 18.04 LTS to 20.04.2 LTS. Unfortunately Qt creator does not have an option for really importing a project. The import option only imports files for editing. It does not do a full import that would allow a successful build.
      So my planned approach is
    7. Create a new empty Qt desktop project.
    8. Copy all my .cpp and .h files from 18.04 LTS to new 20.04.2 LTS project.
    9. Open the new project using 20.04.2 LTS Qt creator.
    10. Try build.
    11. I expect to get errors relating to missing libraries and include files.
    12. Scrum through the Qt 3D example .pro and .pri files patching stuff into my .pro files until I get a successful build.

  • Moderators

    Thank you for posting your detailed steps. Everything you did from #1 to #6 sounds good.

    @C-Cubed said in Need help moving from Ubuntu 18.04 LTS to Ubuntu 20.04.2 LTSs:

    My next step is to try moving my project from 18.04 LTS to 20.04.2 LTS. Unfortunately Qt creator does not have an option for really importing a project.

    You shouldn't need to do anything special to import your project. Just copy your source code directory hierarchy from your original machine into your new machine (but don't copy the *.pro.user file, because this file contains configurations for your specific machine). Then, use Qt Creator to open your top-level *.pro file. Read and fix the error messages from top to bottom (if any).

    P.S. The better way is to use a version control system (such as Git) to store and manage your project. This helps you to track changes in your code over time, and protects you from coding mistakes. It also provides a simple way to load your project on a different machine.



  • Done.
    I've successfully built my Ubuntu 18.04 Qt project on Ubuntu 20.04.2 Qt.
    The process I outlined in my earlier post worked (see above).
    Thankfully I'm only a retired computer professional using Qt for for a small number of home projects .
    Again, thankfully I use the Ubuntu LTS release so I only have to suffer this every 5 years.
    If I were a commercial user, I would be very upset about the difficulty of upgrading Ubuntu 18.04 LTS and Qt to Ubuntu 20.04.02 LTS and Qt. The refactoring of libraries and classes in an incompatible way is none sense. Doing this at a large number of sites with a large number of applications, would be prohibitive.

    Upgrading base Ubuntu is very easy and requires little effort.
    Upgrading mysql, tomcat, eclipse and qt to the newest releases included in newest Ubuntu LTS is very painful.
    Gratuitous Comments:

    1. An automatic upgrade NEVER works.
    2. The major problems are refactoring of libraries and classes and changes to internals of various IDE's
      and GUI's. (eg. project files, ini files, config files etc.)

    These are the changes to my apps I needed to make to get them to build and run under Qt 5 as a result of Qt refactoring.
    1)
    The .pro and .pro.user files are incompatible and have to be redone from scratch
    2) Various classes have been refactored requiring editing include files and possibly cpp files.
    #include <QtGui/QWidget>
    This must be updated to either
    #include <QtWidgets/QWidget>
    Or more portably (Which works in Qt 4 and Qt 5):
    #include <QWidget>

    1. echo "QT += widgets" >> /fileProject.pro
      Add #include QDialog any file containing QDialog declarations
      Previously including QtGui was enough but QT5 splits widgets into more .h files, thus making necessary
      to include them. For example QtMenuBar was included in QtMenu.h but now it requires QtMenuBar.h to
      be #included
    2. This is a hack to catch any/all changes to structure of qt3d. It picks up any new include directories
      Added to .pro file:
      !include( ../Qt/Examples/Qt-5.15.2/qt3d ) {
      error( "Couldn't find the examples.pri file!" )
      }


  • @C-Cubed said in Need help moving from Ubuntu 18.04 LTS to Ubuntu 20.04.2 LTSs:

    1. Various classes have been refactored requiring editing include files and possibly cpp files.
      #include <QtGui/QWidget>
      This must be updated to either
      #include <QtWidgets/QWidget>
      Or more portably (Which works in Qt 4 and Qt 5):
      #include <QWidget>

    That was required to move from Qt4 to Qt5. What does that have to do with your change from Ubuntu 18.04 to 20.04??

    I never edited a single source file moving between those Ubuntu versions.



  • @C-Cubed I am glad you got it working. At least we can celebrate something, despite whatever obstacles got in the way.

    I do find myself agreeing with @JonB , though. I have several projects that have traversed the Ubuntu 18-to-20 threshold, and all my pro and pri files continued work, and I did not edit my source code.

    (Admittedly, I did make one small change, but it was due to a hardcoded QMAKE_CXX = g++-7 in my qmake scripts that had to be changed to a newer compiler version.)

    However, I can think of at least two reasons why my experience would go differently than that of C-Cubed:

    • My pro and pri files have been written by hand, not by Qt Creator.
    • The Qt libraries I link against were ones that I either manually downloaded from the Qt website or else built myself

    I can certainly imagine that depending on how and when the apt/aptitude/synaptic/Ubuntu Software GUI were used for managing the Ubuntu-provided copies of Qt, there could have been a much larger Qt version jump than expected.

    My sense is that this was less a Qt problem than an issue with lack of visibility into apt activities and package versions. (But that's not to say that "Qt problems" never happen.) LTS distributions (in my understanding) are conservative, and (in my experience) tend to keep you "pinned" to very old versions of software longer than you might expect.



  • @KH-219Design
    All of my projects and project files where generated by Qt creator.
    What does it have to do with moving from Ubuntu 18.04 to 20.04.2?

    1. Ubuntu 18.04 LTS is going off support.
    2. Ubuntu 20.04 LTS is the next LTS release. It will be supported for 5 years.
    3. I tried several times to upgrade my 18.04 release using Ubuntu Software manager. I could never get it to work. The upgrade always failed, hosing my system and requiring a complete restore.
    4. Installing 20.04.2 on a naked partition worked 1st time. Very easy, no issues. But, then I was stuck with naked system.
    5. I had to install mysql, Eclipse, Qt , Tomcat9.
      These installs give newer versions for 20.04.2 vs. 18.04.
    6. That's why I had to move my applications.

  • Lifetime Qt Champion

    @C-Cubed said in Need help moving from Ubuntu 18.04 LTS to Ubuntu 20.04.2 LTSs:

    What does it have to do with moving from Ubuntu 18.04 to 20.04.2?

    You misunderstood the question from @JonB
    He asked you why you did this:

    Various classes have been refactored requiring editing include files and possibly cpp files.
    #include <QtGui/QWidget>
    This must be updated to either
    #include <QtWidgets/QWidget>
    Or more portably (Which works in Qt 4 and Qt 5):
    #include <QWidget>
    

    This was only needed when switching from Qt4 to Qt5. But your projects were already Qt5 before moving to Ubuntu 20, right?


Log in to reply