CMake/VS2019: Specified module could not be found



  • I'm using Qt in VS2019 which I have built with CMake. When I run my application I get the error

    "QQmlApplicationEngine failed to load component
    qrc:/main.qml:1:1: Cannot load library C:\Qt62\6.2.1\msvc2019_64\qml\QtQuick\qtquick2plugind.dll: The specified module could not be found."
    

    I have the file at the location specified (my Qt install folder). I've stripped down my code to the bare minimum needed to reproduce this error. My Qml file just cannot seem to import modules. I've specified the import path in my C++ code and also added the qml module in my CMake.

    CMake Code:

    set(CMAKE_CXX_STANDARD 17)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    
    set(CMAKE_AUTOMOC ON)
    set(CMAKE_AUTORCC ON)
    set(CMAKE_AUTOUIC ON)
    
    qt_import_plugins(TouchpadExperiment QWindowsIntegrationPlugin)
    
    find_package(
        Qt6 6.2 COMPONENTS 
            Core
            Quick
            Gui
            Qml
            GuiTools
            CoreTools
            QmlTools
        REQUIRED
    )
    
    qt_add_executable(TouchpadExperiment
        main.cpp
        resources.qrc
    )
    
    qt_add_qml_module(TouchpadExperiment
        URI uri
        VERSION 1.0
        QML_FILES 
            main.qml
    )
    
    target_link_libraries(TouchpadExperiment PRIVATE
        Qt6::Core
        Qt6::Gui 
        Qt6::Quick
        Qt6::Qml
    )
    

    C++ code:

    #include <QGuiApplication>
    #include <QQmlApplicationEngine>
    #include <QQuickWindow>
    
    int main(int argc, char *argv[])
    {
      QGuiApplication app(argc, argv);
    
      QQmlApplicationEngine engine;
      engine.addImportPath("C:/Qt62/6.2.1/msvc2019_64");
      engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    }
    

    QML Code:

    import QtQuick 
    
    Window {
    }
    


  • @Jhalter2 said in CMake/VS2019: Specified module could not be found:

    C:\Qt62\6.2.1\msvc2019_64\qml\QtQuick\qtquick2plugind.dll

    Does this file exist on disk?

    The *d.dll implies a Debug build. Does it work better if you do a Release build?



  • @Crisian-Adam-0 I have verified that the file does exist at that location. I receive the same errors when attempting to run in Release mode.


Log in to reply