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 compilation-Linux -> Win
Forum Updated to NodeBB v4.3 + New Features

cross compilation-Linux -> Win

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
11 Posts 5 Posters 3.1k Views 4 Watching
  • 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.
  • C Offline
    C Offline
    cejohnsonsr
    wrote on last edited by
    #1

    I have a dual boot system running Win10_64 and Linux Mint. I finally got Win to run Qt. I've tested a few things with a trivial project from the tutorials. I can write code in Linux and then open the project in Win, add to it and build/run. Then I can go back to Linux and copy the modified files into my existing project and compile/run with the changes implemented on Win. Seems to work ok both ways. Now what I'm really wanting to figure out is how to do all the coding on Linux and output executable files for both Linux and Windows. I'd appreciate a good step by step, but I'm also willing to do my homework if someone can point me in the right direction. There's so much documentation for Qt that I'm a little lost trying to find my way around. I don't know if it matters or not, but the Win Qt setup is using MSVC 2015 for the compiler. I tried MinGW, but couldn't get it to work. Thanks for any help.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You can't mix and match C++ libraries compiled with different compilers on Windows, the only exception currently being VS2017 that is compatible with VS2015.

      So if you'd like to get started with Qt + MinGW, don't forget to install the compiler packages.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      jsulmJ 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        You can't mix and match C++ libraries compiled with different compilers on Windows, the only exception currently being VS2017 that is compatible with VS2015.

        So if you'd like to get started with Qt + MinGW, don't forget to install the compiler packages.

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

        @SGaist "how to do all the coding on Linux and output executable files for both Linux and Windows" - you mean you want to build for Windows on Linux?
        While this is theoretically possible you should forget about it - it is much easier to build on Windows for Windows.

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

        1 Reply Last reply
        0
        • C Offline
          C Offline
          cejohnsonsr
          wrote on last edited by
          #4

          SGaist, I never had any luck with MinGW in Qt. It would show MinGW as being detected, but wouldn't allow me to select it as the compiler for my project after a build error of "no compiler found". It took me several tries to finally get a working environment on Win as described in the OP.

          jsulm, I could do that, but it's not what I was going for. I read an article about how Qt can be used to output applications for other platforms and even create an installer that includes dynamically linked libraries if necessary. That's what I want to learn how to do.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Often when people have trouble with MinGW is when they install their own version rather than the one coming with the installer. Did you experience something similar ?

            As for the installer, the QtIF allows to build one installer per platform. You can't have one executable that will work on all OS since they are all different. So a native build is still necessary. Even though you could use the MinGW cross-compiler on Linux to generate a Windows executable it can be pretty involved and also you can't make use of native API if needed by your application., You should rather do native compilation for the platform you want support. Visual Machines are now pretty easy to setup for that kind of tasks.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            mrjjM 1 Reply Last reply
            3
            • SGaistS SGaist

              Often when people have trouble with MinGW is when they install their own version rather than the one coming with the installer. Did you experience something similar ?

              As for the installer, the QtIF allows to build one installer per platform. You can't have one executable that will work on all OS since they are all different. So a native build is still necessary. Even though you could use the MinGW cross-compiler on Linux to generate a Windows executable it can be pretty involved and also you can't make use of native API if needed by your application., You should rather do native compilation for the platform you want support. Visual Machines are now pretty easy to setup for that kind of tasks.

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi
              Cross Compiling from window to linux or from linux to windows is a huge pain in the time table.
              Installing a virtual machine and setup Qt might take 1-2 hours at max.
              Cross Compiling ALL of the tool chain ( u can get predefined sometimes for mingw ) + Qt to be able to output a windows .exe in linux is very complicated
              and while possible its not a nice solution as you will need to do it all over again if upgrading Qt etc.
              Also u cannot debug the app in linux..
              Also it took 3 days to get it running and it still had issues with Qt. And he was a toolchain expert. I gave up since
              there are no real good tuts or info. Its not used by many due to all the limitations.

              http://stackoverflow.com/questions/2033997/how-to-compile-for-windows-on-linux-with-gcc-g

              So yes, its possible but it not really useful for real development as i see it and very time consuming to get running and even worse to maintain as not
              widely used so setting up a wm is so much more productive and functional. Also hard drives are cheap so in time/cost calculations its a bad solution to try
              to setup cross compile.

              I

              the_T 1 Reply Last reply
              1
              • mrjjM mrjj

                Hi
                Cross Compiling from window to linux or from linux to windows is a huge pain in the time table.
                Installing a virtual machine and setup Qt might take 1-2 hours at max.
                Cross Compiling ALL of the tool chain ( u can get predefined sometimes for mingw ) + Qt to be able to output a windows .exe in linux is very complicated
                and while possible its not a nice solution as you will need to do it all over again if upgrading Qt etc.
                Also u cannot debug the app in linux..
                Also it took 3 days to get it running and it still had issues with Qt. And he was a toolchain expert. I gave up since
                there are no real good tuts or info. Its not used by many due to all the limitations.

                http://stackoverflow.com/questions/2033997/how-to-compile-for-windows-on-linux-with-gcc-g

                So yes, its possible but it not really useful for real development as i see it and very time consuming to get running and even worse to maintain as not
                widely used so setting up a wm is so much more productive and functional. Also hard drives are cheap so in time/cost calculations its a bad solution to try
                to setup cross compile.

                I

                the_T Offline
                the_T Offline
                the_
                wrote on last edited by
                #7

                @mrjj
                http://mxe.cc works but is really pain (you know where ;) )... and it does static building

                -- No support in PM --

                1 Reply Last reply
                1
                • C Offline
                  C Offline
                  cejohnsonsr
                  wrote on last edited by
                  #8

                  "Often when people have trouble with MinGW is when they install their own version rather than the one coming with the installer. Did you experience something similar ?"

                  Are you talking about the MinGW installer or the Qt installer? I tried the online installer for MinGW and also downloaded a zip file that looks to be just a folder containing all the tools and libraries. I never got to try the zip version because at about the same time I found the MSVC Build Tools 2015 and it worked, although there was an issue with that too. I had to completely uninstall Visual Studio 2017 and any runtimes from 2015 on and delete the folders before MSVC Build Tools would install properly and work with Qt.

                  mrjjM 1 Reply Last reply
                  0
                  • C cejohnsonsr

                    "Often when people have trouble with MinGW is when they install their own version rather than the one coming with the installer. Did you experience something similar ?"

                    Are you talking about the MinGW installer or the Qt installer? I tried the online installer for MinGW and also downloaded a zip file that looks to be just a folder containing all the tools and libraries. I never got to try the zip version because at about the same time I found the MSVC Build Tools 2015 and it worked, although there was an issue with that too. I had to completely uninstall Visual Studio 2017 and any runtimes from 2015 on and delete the folders before MSVC Build Tools would install properly and work with Qt.

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    @cejohnsonsr said in cross compilation-Linux -> Win:

                    Are you talking about the MinGW installer or the Qt installer?

                    The Qt installer. The mingw Qt precompiled packet comes with
                    mingw compiler and debugger. ( UNLIKE the vs201X ones)

                    Often if u install some OTHER mingw from other source it can give issues.

                    C 1 Reply Last reply
                    0
                    • mrjjM mrjj

                      @cejohnsonsr said in cross compilation-Linux -> Win:

                      Are you talking about the MinGW installer or the Qt installer?

                      The Qt installer. The mingw Qt precompiled packet comes with
                      mingw compiler and debugger. ( UNLIKE the vs201X ones)

                      Often if u install some OTHER mingw from other source it can give issues.

                      C Offline
                      C Offline
                      cejohnsonsr
                      wrote on last edited by
                      #10

                      @mrjj, well that might explain it. I took the installation instructions to mean that I had to install the compiler myself.

                      mrjjM 1 Reply Last reply
                      0
                      • C cejohnsonsr

                        @mrjj, well that might explain it. I took the installation instructions to mean that I had to install the compiler myself.

                        mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on last edited by mrjj
                        #11

                        @cejohnsonsr
                        Well that is also possible but the issue is that Qt is shared libs. (DLLS)
                        And to use them with other compiler than used to produce them, stops working very fast.

                        But its possible to install what ever mingw version and compile all Qt with it.
                        That always works. But if you dont need a special version of mingw ( older/newer) then
                        just using the included one is far more fun.

                        Also for VS. it must match 100%. So u cant install say have vs 2013 and use Qt for 2015.
                        Only exception it seem sis that Qt 2015 DOES work with vs2017.

                        1 Reply Last reply
                        1

                        • Login

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