building issues with wrong qmake version



  • Hello everyone
    This post is somehow in between installation and building. A few days ago I installed QT 5.9.1. I used QT Creator which just works perfectly. However I want to include QT in an existing project which is controlled by git and thus use QT creator only for UI placement. However I faced/ I am facing some issues here:
    [I seem to have installed a QT 4.x version a longer time ago which I did not uninstall]

    1st (solved myself): using qmake I was not able to compile for 5.9.1 but only 4.x . I followed the symlink from qmake in /usr/bin to qtchooser. There I deleted 4.conf and qt4.conf, keeping 5.conf and qt5.conf. This didn't work out so I manually created a default.conf file containing the qt5 bin and lib path. This worked out.

    2nd (solved dirty): Now qmake was the right version. However make told me that it could not find qdialog.h. Checking the makefile myself I discovered that for the include the entry for ".../QtWidgets/" was missing. I entered this manually which made it compile successfully. Is there a clean way ? Or is it just a bug from qmake ?

    3rd (not solved): After successful compilation I received dozens of "undefined reference to...". (I do not show as I did not find the "spoiler" function for posting. However I guess there is some option in the makefile missing or I have to copy some .so file into this folder. I was just not able to figure this out myself. Some examples of the unresolved references:

    main.cpp:(.text.startup+0x81): Nicht definierter Verweis auf QApplication::~QApplication()' main.cpp:(.text.startup+0xd1): Nicht definierter Verweis aufQDialog::~QDialog()'
    main.cpp:(.text.startup+0xd9): Nicht definierter Verweis auf QApplication::~QApplication()' dialog.o: In FunktionDialog::createMenu()':
    dialog.cpp:(.text+0x30): Nicht definierter Verweis auf QMenuBar::QMenuBar(QWidget*)' dialog.cpp:(.text+0x73): Nicht definierter Verweis aufQMenu::QMenu(QString const&, QWidget*)'

    Greetings and thanks in advance
    Moritz



  • @moritzP said in building issues with wrong qmake version:

    3rd (not solved): After successful compilation I received dozens of "undefined reference to...". (I do not show as I did not find the "spoiler" function for posting. However I guess there is some option in the makefile missing or I have to copy some .so file into this folder. I was just not able to figure this out myself. Some examples of the unresolved references:I

    If you have a makefile i suppose is not on Window system...
    I have seen gigantic differences from qt4 to qt5, very often it is enough to accept other view point from program something new from another corner (aus einem neuen blickwinkel ansehen) and not put any association on the previous version.

    This output error in german is this from Linux debian?



  • Hey,

    Sorry I forgot to tell you my os. yes I use Xubuntu 16.04 (LTSE)
    and yes, I'm german.

    Greetings
    Moritz


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Any chance that you are calling just qmake on the command line ?

    If so that's the problem, you are calling your distribution installed qmake which is likely Qt 4 from what you wrote.

    Use the full path every time you are on the console so you ensure that you are using the correct Qt version.



  • Thank you.
    Yes. Actually if I ONLY issue qmake a Makefile is generated with the following header:

    # Makefile for building: dialog
    # Generated by qmake (3.1) (Qt 5.9.1)
    # Project:  dialog.pro
    # Template: app
    # Command: /home/moritz/Qt/5.9.1/gcc_64/bin/qmake -o Makefile dialog.pro
    

    And my dialog.pro:

    SOURCES = main.cpp \
            dialog.cpp
    HEADERS = dialog.h
    TARGET = dialog
    CONFIG += QT
    

    //edit
    so this seems fine but I write c++ code and thus I want it to compile with g++. But there is no g++ folder only that gcc. Do I have to issue anything to qmake to make this clear ?

    Greetings
    Moritz

    //edit2
    the "building" issues is incorrect because I did not build it but installed the .run file. so it's rather installation issues. with building I meant compilation. Any advice what to do ? Problem number 2 and 3 are still remaining


  • Moderators

    @moritzP Please add

    QT += core gui widgets
    

    to your pro file, then run qmake again and rebuild.
    Regarding number 3: if you start your app manually (not from QtCreator) you first have to deploy it, so the system can find needed Qt libraries. See http://doc.qt.io/qt-5/linux-deployment.html



  • doing a make clean and adding

    QT += core gui widgets
    

    did the trick. You saved my day, thank you !
    I did not have to do any specific linking. Just run qmake and ./dialog (executable) will show up the dialog window. Maybe qmake does more than I expected it to do ?

    Thanks everyone for helping me ! This is solved.


  • Moderators

    @moritzP said in building issues with wrong qmake version:

    Maybe qmake does more than I expected it to do ?

    No, it looks like on your system the Qt libraries are in a known location (like /usr/lib), or LD_LIBRARY_PATH is pointing to the location.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.