Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. cross-compiling from Linux to get an executable windows
Servers for Qt installer are currently down

cross-compiling from Linux to get an executable windows

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
2 Posts 2 Posters 161 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.
  • grafenocarbonoG Offline
    grafenocarbonoG Offline
    grafenocarbono
    wrote last edited by
    #1

    Hello,

    I am trying to compile from Linux a Windows executable.

    I have create the following script:

    sudo apt install mingw-w64 -y
    mkdir build-win && cd build-win
    cmake  \
      -DCMAKE_TOOLCHAIN_FILE=../mingw_toolchain.cmake \
      -DCMAKE_PREFIX_PATH=/path/to/Qt/6.x.x/mingw_64/lib/cmake
    
    make```
    
    My CMakeLists.txt is the following one:
    
    ```cmake_minimum_required(VERSION 3.16)
    
    project(hello_world LANGUAGES CXX)
    
    set(CMAKE_AUTOUIC ON)
    set(CMAKE_AUTOMOC ON)
    set(CMAKE_AUTORCC ON)
    
    set(CMAKE_CXX_STANDARD 17)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    
    find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
    find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core)
    
    set(CMAKE_SYSTEM_NAME Windows)
    set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
    set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
    
    
    add_executable(hello_world
      main.cpp
    )
    target_link_libraries(hello_world Qt${QT_VERSION_MAJOR}::Core)
    
    include(GNUInstallDirs)
    install(TARGETS hello_world
        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
        RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
    )
    

    When I execute my script I get the following error:

      No source or binary directory provided.  Both will be assumed to be the
      same as the current working directory, but note that this warning will
      become a fatal error in future CMake releases.
    
    
    CMake Error: The source directory "/home/leyva/QtProjects/hello_world/build-win" does not appear to contain CMakeLists.txt.
    Specify --help for usage, or press the help button on the CMake GUI.
    make: *** No targets specified and no makefile found.  Stop.
    

    Thanks in advance.

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote last edited by
      #2

      As the error message tells you, you forgot to specify the source directory.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      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 Extensions
      • Unsolved