Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Building Qt6 WebAssembly GUI with Emscripten fails because of missing GLESv2/EGL
Qt 6.12 LTS is out! See what's new in the release blog

Building Qt6 WebAssembly GUI with Emscripten fails because of missing GLESv2/EGL

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
1 Posts 1 Posters 722 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    qwendt
    wrote on last edited by
    #1

    Since weeks I try to build my complete project. Every time i want to use a new library the troubles start from scratch. No I want to use cpr for my http client. I am currently trying to build a Qt6 GUI project for WebAssembly using Emscripten.
    My setup:

    • Qt 6.8.3 (wasm_singlethread)

    • Emscripten SDK (latest, emcc/em++)

    • CMake 3.31 (via CLion 2025.1.3)

    • Using Qt’s qt.toolchain.cmake and chaining Conan’s toolchain for dependencies (spdlog, cpr, nlohmann_json, …)

    This is my CMakeLists.txt

    cmake_minimum_required(VERSION 3.21)
    project(qt3d_wasm_project VERSION 0.1 LANGUAGES CXX)
    message(STATUS "CMAKE_SYSTEM_NAME = ${CMAKE_SYSTEM_NAME}")
    if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
        if(NOT TARGET emscripten_flags)
            add_library(emscripten_flags INTERFACE)
            target_link_options(emscripten_flags INTERFACE
                    "SHELL:-sUSE_ZLIB=1"
                    # "SHELL:-sFETCH=1" #maybe i will need this later for crp /libcurl
            )
        endif()
    
        if(NOT TARGET GLESv2::GLESv2)
            add_library(GLESv2::GLESv2 INTERFACE IMPORTED GLOBAL)
            target_link_options(GLESv2::GLESv2 INTERFACE "SHELL:-sUSE_WEBGL2=1")
        endif()
        if(NOT TARGET EGL::EGL)
            add_library(EGL::EGL INTERFACE IMPORTED GLOBAL)
            target_link_options(EGL::EGL INTERFACE "SHELL:-sUSE_WEBGL2=1")
        endif()
    endif()
    
    add_subdirectory(libraries/material_data_lib)
    
    if(ENABLE_GUI)
        find_package(Qt6 REQUIRED COMPONENTS Core Gui Quick Quick3D Qml Quick3DHelpers Network)
    
        qt_add_executable(appqt3d
                resources.qrc
                main.cpp
                libraries/material_data_lib/include/IMaterialDataFetcher.h
                libraries/material_data_lib/src/MaterialDataFactory.cpp
        )
    
        if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
            target_link_libraries(appqt3d PRIVATE emscripten_flags  GLESv2::GLESv2 EGL::EGL)
        endif()
    
        target_link_libraries(appqt3d PRIVATE
                Qt6::Core Qt6::Gui Qt6::Quick Qt6::Quick3D Qt6::Quick3DHelpers Qt6::Network
        )
    endif()
    
    

    My CMake Options that i use:

    -DCMAKE_TOOLCHAIN_FILE=/home/emmynoether/Qt/6.8.3/wasm_singlethread/lib/cmake/Qt6/qt.toolchain.cmake
    -DQT_CHAINLOAD_TOOLCHAIN_FILE=/home/emmynoether/Dokumente/Webseite/MaterialStack/build_wasm/build/Release/generators/conan_toolchain.cmake
    -DENABLE_GUI=ON
    -DBUILD_TESTING=OFF
    -DQt6_DIR=/home/emmynoether/Qt/6.8.3/wasm_singlethread/lib/cmake/Qt6
    -DQT_HOST_PATH=/home/emmynoether/Qt/6.8.3/gcc_64
    -DQT_DEBUG_FIND_PACKAGE=ON
    

    The Output of CMake:

    -- Could NOT find EGL (missing: HAVE_EGL) (found version "1.5")
    -- Could NOT find GLESv2 (missing: GLESv2_INCLUDE_DIR GLESv2_LIBRARY HAVE_GLESv2 HAVE_GLESv2) 
    CMake Warning at /home/emmynoether/Qt/6.8.3/wasm_singlethread/lib/cmake/Qt6/Qt6Config.cmake:196 (find_package):
      Found package configuration file:
    
        /home/emmynoether/Qt/6.8.3/wasm_singlethread/lib/cmake/Qt6Gui/Qt6GuiConfig.cmake
    
      but it set Qt6Gui_FOUND to FALSE so package "Qt6Gui" is considered to be
      NOT FOUND.  Reason given by package:
    
      Qt6Gui could not be found because dependency GLESv2 could not be found.
    
      Configuring with --debug-find-pkg=GLESv2 might reveal details why the
      package was not found.
    
       find_package search path values and other context for the last package that was not found:
        CMAKE_MODULE_PATH: /home/emmynoether/Qt/6.8.3/wasm_singlethread/lib/cmake/Qt6/platforms;/home/emmynoether/Dokumente/Webseite/MaterialStack/build_wasm/build/Release/generators;/home/emmynoether/Qt/6.8.3/wasm_singlethread/lib/cmake/Qt6;/home/emmynoether/Qt/6.8.3/wasm_singlethread/lib/cmake/Qt6/3rdparty/extra-cmake-modules/find-modules;/home/emmynoether/Qt/6.8.3/wasm_singlethread/lib/cmake/Qt6/3rdparty/kwin
        CMAKE_PREFIX_PATH: /home/emmynoether/Qt/6.8.3/wasm_singlethread/lib/cmake;/home/emmynoether/Dokumente/Webseite/MaterialStack/build_wasm/build/Release/generators
        $ENV{CMAKE_PREFIX_PATH}: 
        CMAKE_FIND_ROOT_PATH: /home/emmynoether/Qt/6.8.3/wasm_singlethread
        _qt_additional_packages_prefix_paths: 
        _qt_additional_host_packages_prefix_paths: 
        _qt_cmake_dir: /home/emmynoether/Qt/6.8.3/wasm_singlethread/lib/cmake
        QT_HOST_PATH: /home/emmynoether/Qt/6.8.3/gcc_64
        Qt6HostInfo_DIR: /home/emmynoether/Qt/6.8.3/gcc_64/lib/cmake/Qt6HostInfo
        Qt6_DIR: /home/emmynoether/Qt/6.8.3/wasm_singlethread/lib/cmake/Qt6
        CMAKE_TOOLCHAIN_FILE: /home/emmynoether/Qt/6.8.3/wasm_singlethread/lib/cmake/Qt6/qt.toolchain.cmake
        CMAKE_FIND_ROOT_PATH_MODE_PACKAGE: BOTH
        CMAKE_SYSROOT: 
        $ENV{PATH}: /home/emmynoether/emsdk/upstream/emscripten:/home/emmynoether/emsdk/node/22.16.0_64bit/bin:/home/emmynoether/.local/bin:/home/emmynoether/.local/bin:/home/emmynoether/.local/bin:/home/emmynoether/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/emmynoether/.dotnet/tools:/home/emmynoether/Downloads/clion-2025.1.3/bin/ninja/linux/x64
    
    Call Stack (most recent call first):
      CMakeLists.txt:26 (find_package)
    
    

    Even though Qt6GuiConfig.cmake exists in wasm_singlethread/lib/cmake/Qt6Gui/ , it refuses to mark Qt6Gui_FOUND as TRUE because FindWrapGLESv2.cmake did not succeed.

    Why does Qt6GuiConfig.cmake for WebAssembly still insist on “real” GLESv2/EGL libraries, even though WebAssembly uses WebGL via Emscripten?
    Is there a recommended way to make Qt6Gui’s dependency resolution happy in a WASM build without hacking its CMake files?
    thank you

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt
    • Unsolved