Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Cross-compiling Qt for Linux on Windows

Cross-compiling Qt for Linux on Windows

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 5 Posters 9.6k 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.
  • D Offline
    D Offline
    Donald Duck
    wrote on last edited by
    #1

    I'm trying to configure Qt Creator so that I can cross-compile Linux programs on Windows. I know that I can use a virtual machine, but my virtual machine is very slow so it would be nice if I don't have to run it every time I want to release an update for one of my programs.

    I already have a working Linux compiler and working Qt binaries for Linux. The Linux compiler is a small .exe file that I made that calls wsl.exe gcc with the right arguments, which runs the gcc compiler on a Windows subsystem for Linux. The Qt binaries for Linux are the binaries that came with Qt when I installed it on my Linux virtual machine, so I just copied the files from ~/Qt/5.15.12/gcc_64 on my virtual machine to C:\Qt\5.15.12\gcc_64 on Windows. I also created a C:\Qt\5.15.12\gcc_64\bin\qmake.exe file that calls wsl.exe /mnt/c/Qt/5.15.12/gcc_64/bin/qmake with the right arguments, which runs the Linux qmake on a Windows subsystem for Linux.

    So I have a working Linux compiler and working Qt binaries for Linux, but the problem is that I haven't managed to configure Qt Creator to use them. For the compiler, I went to Tools > Options > Compilers and added the Linux compiler manually, which Qt Creator seems to accept, but for the Qt binaries, I went to Tools > Options > Qt Versions and added C:\Qt\5.15.12\gcc_64\bin\qmake.exe, but Qt Creator gives me an error saying that "Qt version is not properly installed, please run make install". I assume it wants me to install it from the maintenance tool, but I can't since the maintenance tool for Windows doesn't have an option to install Linux binaries.

    alt text

    What I want to do is create a "Linux" kit which uses the Linux compiler and the Linux Qt binaries. How do I configure Qt Creator to do this?

    1 Reply Last reply
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #3

      @Donald-Duck said in Cross-compiling Qt for Linux on Windows:

      I also created a C:\Qt\5.15.12\gcc_64\bin\qmake.exe file that calls wsl.exe /mnt/c/Qt/5.15.12/gcc_64/bin/qmake with the right arguments, which runs the Linux qmake on a Windows subsystem for Linux.

      Out of curiosity, what happens when you call qmake.exe -query on your custom executable? This is what Qt Creator was checking when it told you "Qt version is not properly installed"

      I'm guessing that, at best, qmake.exe -query prints Linux paths (as seen from WSL). Linux paths are unusable to the Windows version of Qt Creator.

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      D 1 Reply Last reply
      2
      • 6thC6 Offline
        6thC6 Offline
        6thC
        wrote on last edited by 6thC
        #2

        so I just copied the files from ~/Qt/5.15.12/gcc_64

        Narrator: It was at this point OP knew they messed up good.

        You can't do that. https://gcc.gnu.org/install/binaries.html
        I would assume there is near absolute zero support for trying to do what you are now. As everyone else just goes down the path of least resistance and uses what works out of the box. It's why we use tools/frameworks after all, so we don't get bogged down in the infrastructure and more on the project unique code.

        What you get out of the box (MinGW) is the best that works already and you already have it installed correctly because it's from the online installer and your screenshot looks good.
        Except for the bit where you've tried to manually jigger the GCC compiler onto Windows by just copying files - which Creator correctly says: no. That's not how you'd even begin to approach that so I would stop try that right there.

        MSVC | MinGW on windows builds.
        GCC on linux.

        I'd say you might:
        try getting another machine to build linux?
        use an online build server (if something like that exists) to generate your binaries?
        deal with it by continue to wait

        1 Reply Last reply
        0
        • JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on last edited by
          #3

          @Donald-Duck said in Cross-compiling Qt for Linux on Windows:

          I also created a C:\Qt\5.15.12\gcc_64\bin\qmake.exe file that calls wsl.exe /mnt/c/Qt/5.15.12/gcc_64/bin/qmake with the right arguments, which runs the Linux qmake on a Windows subsystem for Linux.

          Out of curiosity, what happens when you call qmake.exe -query on your custom executable? This is what Qt Creator was checking when it told you "Qt version is not properly installed"

          I'm guessing that, at best, qmake.exe -query prints Linux paths (as seen from WSL). Linux paths are unusable to the Windows version of Qt Creator.

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          D 1 Reply Last reply
          2
          • JKSHJ JKSH

            @Donald-Duck said in Cross-compiling Qt for Linux on Windows:

            I also created a C:\Qt\5.15.12\gcc_64\bin\qmake.exe file that calls wsl.exe /mnt/c/Qt/5.15.12/gcc_64/bin/qmake with the right arguments, which runs the Linux qmake on a Windows subsystem for Linux.

            Out of curiosity, what happens when you call qmake.exe -query on your custom executable? This is what Qt Creator was checking when it told you "Qt version is not properly installed"

            I'm guessing that, at best, qmake.exe -query prints Linux paths (as seen from WSL). Linux paths are unusable to the Windows version of Qt Creator.

            D Offline
            D Offline
            Donald Duck
            wrote on last edited by
            #4

            @JKSH said in Cross-compiling Qt for Linux on Windows:

            I'm guessing that, at best, qmake.exe -query prints Linux paths (as seen from WSL).

            Thanks. I changed the qmake.exe program so that it changes Linux paths in the output to Windows paths. Now Qt Creator is accepting it, so now I can use the kit.

            The problem now is that when I try to compile my programs using that kit, I get an error saying

            Could not start process "make" -f C:/Users/glind/AppData/Local/Temp/untitled2/build-untitled2/Makefile qmake_all
            

            I guess that's normal since the Make it's using is probably not the one for Linux, but how do I configure it to know which Make to use? I've found how to configure CMake in Qt Creator (and I've done that), but how do I configure Make? I could easily make a make.exe program which calls wsl.exe make with the right arguments, but how do I configure Qt Creator to use it?

            jsulmJ 1 Reply Last reply
            0
            • D Donald Duck

              @JKSH said in Cross-compiling Qt for Linux on Windows:

              I'm guessing that, at best, qmake.exe -query prints Linux paths (as seen from WSL).

              Thanks. I changed the qmake.exe program so that it changes Linux paths in the output to Windows paths. Now Qt Creator is accepting it, so now I can use the kit.

              The problem now is that when I try to compile my programs using that kit, I get an error saying

              Could not start process "make" -f C:/Users/glind/AppData/Local/Temp/untitled2/build-untitled2/Makefile qmake_all
              

              I guess that's normal since the Make it's using is probably not the one for Linux, but how do I configure it to know which Make to use? I've found how to configure CMake in Qt Creator (and I've done that), but how do I configure Make? I could easily make a make.exe program which calls wsl.exe make with the right arguments, but how do I configure Qt Creator to use it?

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #5

              @Donald-Duck said in Cross-compiling Qt for Linux on Windows:

              but how do I configure it to know which Make to use?

              "Projects/Build & Run/Build/Build Steps/Make"

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              D 1 Reply Last reply
              2
              • jsulmJ jsulm

                @Donald-Duck said in Cross-compiling Qt for Linux on Windows:

                but how do I configure it to know which Make to use?

                "Projects/Build & Run/Build/Build Steps/Make"

                D Offline
                D Offline
                Donald Duck
                wrote on last edited by
                #6

                @jsulm Thanks, it worked.

                Pablo J. RoginaP 1 Reply Last reply
                0
                • D Donald Duck

                  @jsulm Thanks, it worked.

                  Pablo J. RoginaP Offline
                  Pablo J. RoginaP Offline
                  Pablo J. Rogina
                  wrote on last edited by
                  #7

                  @Donald-Duck said in Cross-compiling Qt for Linux on Windows:

                  it worked.

                  great. So please don't forget to mark your post as solved!

                  Upvote the answer(s) that helped you solve the issue
                  Use "Topic Tools" button to mark your post as Solved
                  Add screenshots via postimage.org
                  Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                  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