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

Qt Creator fails to link



  • Hello,

    I've been tinkering with Qt Creator in Windows 7 for a while and it has worked as expected, but now I got a new computer with Windows 10 and installed Qt Creator on that one and linking fails. Compiling works though.

    I've tested some different examples from Qt Creator, like analogclock, and in Configure Project I choose "Desktop Qt 5.12.1 MinGW 64-bit", hit "Configure Project" and try to build. My "Compile Output" window gets completely spammed with:

    g++ -Wl,-subsystem,windows -mthreads -o debug\analogclock.exe debug/rasterwindow.o debug/main.o debug/moc_rasterwindow.o  -LC:\Qt\5.12.1\mingw73_64\lib C:\Qt\5.12.1\mingw73_64\lib\libQt5Guid.a C:\Qt\5.12.1\mingw73_64\lib\libQt5Cored.a  -lmingw32 C:\Qt\5.12.1\mingw73_64\lib\libqtmaind.a -LC:\openssl\lib -LC:\Utils\my_sql\mysql-5.6.11-winx64\lib -LC:\Utils\postgresql\pgsql\lib -lshell32 -LC:\Qt\5.12.1\mingw73_64\lib C:\Qt\5.12.1\mingw73_64\lib\libQt5Cored.a 
    debug/rasterwindow.o: In function `ZN12RasterWindowC2EP7QWindow':
    C:\Qt\Examples\Qt-5.12.1\gui\build-analogclock-Desktop_Qt_5_12_1_MinGW_64_bit-Debug/../rasterwindow/rasterwindow.cpp:56: undefined reference to `_imp___ZN7QWindowC2EPS_'
    C:\Qt\Examples\Qt-5.12.1\gui\build-analogclock-Desktop_Qt_5_12_1_MinGW_64_bit-Debug/../rasterwindow/rasterwindow.cpp:56: undefined reference to `_imp___ZN13QBackingStoreC1EP7QWindow'
    C:\Qt\Examples\Qt-5.12.1\gui\build-analogclock-Desktop_Qt_5_12_1_MinGW_64_bit-Debug/../rasterwindow/rasterwindow.cpp:58: undefined reference to `_imp___ZN7QWindow11setGeometryEiiii'
    C:\Qt\Examples\Qt-5.12.1\gui\build-analogclock-Desktop_Qt_5_12_1_MinGW_64_bit-Debug/../rasterwindow/rasterwindow.cpp:56: undefined reference to `_imp___ZN7QWindowD2Ev'
    

    And so on.

    I've installed the complete "Qt 5.12.1" kit plus the packages "Qt Creator 4.8.1 CDB Debugger Support", "MinGW 7.3.0 32-bit" (7.3.0-0) and "MinGW 7.3.0 64-bit" (7.3.0-1), I've tried to reboot, to do a full clean of the project etc. Nothing seems to help, linking just won't happen.

    I bet it's a path that is broken, but where? Totally stuck here.

    Help?



  • @etla

    Hi and welcome to devent forum

    Did you check the different tabs under "Tools"->"Options"->"Kits" ?
    Have a look for special signs in yellow and red.


  • Lifetime Qt Champion

    @etla

    I wonder why your linker command line contains these libs:

    -LC:\openssl\lib -LC:\Utils\my_sql\mysql-5.6.11-winx64\lib -LC:\Utils\postgresql\pgsql\lib -lshell32

    I'm pretty sure these shouldn't exist in a Qt example. I'm not sure how they got there, though.



  • I've got it to work after messing around with the components. First I tried uninstalling everything and only add Qt 5.12.1 and 64-bit support, didn't fly. I'm not entirely sure which step that made things work, but I THINK that the two things that made things break was:

    • Don't install both MinGW 64-bit AND MinGW 32-bit. You will get 64-bit compilers but 32-bit gdb and nothing will work.
    • I THINK that not everything gets set up correctly if you install QT Creator and MinGW 64-bit at the same time. Start with installing QT Creator first, THEN add a Qt-kit (like Qt 5.12.1).

    But as I said, I've messed around too much to be sure what fixed it, but I think things solved itself by me trying to test the 32-bit environment only by installing MinGW 32-bit and uninstalling MinGW 64-bit (pro tip, it won't work in a 64-bit environment, no point in trying) and when I afterwards uninstalled the 32-bit and reinstalled 64-bit things just fell into place and the "Desktop Qt 5.12.1 MinGW 64-bit" kit just ... worked. So I'll just stop messing with it now and just leave it as it is!

    Thanks Koahnig for the tip to look at the kits. That's what made me start poking around in there and eventually solve the problem (somehow?).

    aha_1980: Yeah, I double checked with the old machine. The linking arguments were identical and even though I agree that those things seems misplaced in a pure Qt example it seems that it's supposed to be like that (and now it works on the new machine as well).



  • @etla

    Best is to install MinGW through Qt online installer as well. I have in parallel MinGW 32 bit and 64 bit installed, but this is done through online installer.
    When installing MinGW manually from other sources you have to be careful. IIRC there might be added something to the path.

    Qt 5.12 is the first precompiled version for MinGW 64 bit. Therefore you need to ensure that the correct compiler is installed then.
    The 32 bit compiler cannot work.

    Up to Qt5.11 there was only a 32 bit prebuilt available.



  • @koahnig Yeah, I used the one distributed with the installer, but I think the reason that it failed was because there might have been paths for the linker that wasn't properly set up if you selected to install the Qt Creator and the Qt kit at the same time.

    When I installed the older computer I think I installed the kit afterwards because I wasn't aware of that I needed to manually select it at installation time.


Log in to reply