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

emit(s) build errors using mingw64



  • Sorry for the several posts the last couple of days but here is the latest. I have an application that has been working for a month and I have been making minor changes to it. I was using msvc 2019 until I had to do an update to it and everything just seemed to fall apart. Finally I have given up and decided to use Mingw64 instead. Everything builds fine except I get a undefined reference error to every emit call in the program, a couple of errors - undefined reference to vtable and finally collect2.exe returned exit status of 1. Any Ideas before I just give up on Qt. I used to use it exclusively years ago and never had the kind of problems I seem to be fighting with every day now. Oh I am using Cmake not qmake with Qt 6.0.1. Any help would be greatly appreciated.


  • Lifetime Qt Champion

    Please show your cmake script. Did you enable AUTOMOC or do you use another way to generate the moc files?



  • @Christian-Ehrlicher When you say the Cmake script do you mean the CmakeLists.txt if so here is what I have.

    cmake_minimum_required(VERSION 3.5)
    
    project(DXT LANGUAGES CXX)
    
    set(CMAKE_INCLUDE_CURRENT_DIR ON)
    
    set(CMAKE_AUTOUIC ON)
    set(CMAKE_AUTOMOC ON)
    set(CMAKE_AUTORCC ON)
    
    set(CMAKE_CXX_STANDARD 11)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    
    # QtCreator supports the following variables for Android, which are identical to qmake Android variables.
    # Check https://doc.qt.io/qt/deployment-android.html for more information.
    # They need to be set before the find_package( ...) calls below.
    
    #if(ANDROID)
    #    set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
    #    if (ANDROID_ABI STREQUAL "armeabi-v7a")
    #        set(ANDROID_EXTRA_LIBS
    #            ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libcrypto.so
    #            ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libssl.so)
    #    endif()
    #endif()
    
    find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets REQUIRED)
    find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets REQUIRED)
    
    set(PROJECT_SOURCES
        main.cpp
        mainwindow.cpp
        ditaTransform.cpp
        procedure.cpp
        processDitaConcept.cpp
        processDitaTitle.cpp
        processDitaHeaderandProlog.cpp
        processDitaConbody.cpp
        processDitaSteps.cpp
        processBranching.cpp
        writeXmlFile.cpp
        mainwindow.h
        ditaTransform.h
        procedure.h
        mainwindow.ui
        icons.qrc
    )
    
    if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
        set(app_icon_resource_windows "${CMAKE_CURRENT_SOURCE_DIR}/icons.rc")
        qt_add_executable(DXT ${PROJECT_SOURCES} ${app_icon_resource_windows})
    
        #qt_add_executable(DXT
        #    ${PROJECT_SOURCES}
        #)
    else()
        if(ANDROID)
            add_library(DXT SHARED
                ${PROJECT_SOURCES}
            )
        else()
            add_executable(DXT
                ${PROJECT_SOURCES}
            )
        endif()
    endif()
    
    target_link_libraries(DXT PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
    

  • Lifetime Qt Champion

    Are moc files generated in to build dir? Do you use a clean build dir? Are you sure you use the correct Qt version (for MinGW) and did not mix up with the MSVC binaries?



  • @Christian-Ehrlicher Wow that did it...Thank you very much I have no idea what happened. It is a brand new install of Qt 6.0.1 with a brand new build directory. I deleted the directory and did a build again and it works. Thanks again!!


  • Lifetime Qt Champion

    @shathcock Nice. lease don't forget to mark the topic as solved then.



  • @Christian-Ehrlicher Just about to Thanks again!! It has been a very frustrating couple of days.


  • Lifetime Qt Champion

    The first thing to do with sch problems is to start with a clean build dir :)


Log in to reply