Building a windows executable in qt on a Linux system












5















I have been having the hardest time trying to compile a .pro file in Linux to make a windows executable. I have read all the links in the world on using mingw and nothing has worked as of yet. Is there something I'm missing or does anyone have a really good step by step on how to do this?



Ubuntu 14.04.2
QT 4.8










share|improve this question



























    5















    I have been having the hardest time trying to compile a .pro file in Linux to make a windows executable. I have read all the links in the world on using mingw and nothing has worked as of yet. Is there something I'm missing or does anyone have a really good step by step on how to do this?



    Ubuntu 14.04.2
    QT 4.8










    share|improve this question

























      5












      5








      5


      1






      I have been having the hardest time trying to compile a .pro file in Linux to make a windows executable. I have read all the links in the world on using mingw and nothing has worked as of yet. Is there something I'm missing or does anyone have a really good step by step on how to do this?



      Ubuntu 14.04.2
      QT 4.8










      share|improve this question














      I have been having the hardest time trying to compile a .pro file in Linux to make a windows executable. I have read all the links in the world on using mingw and nothing has worked as of yet. Is there something I'm missing or does anyone have a really good step by step on how to do this?



      Ubuntu 14.04.2
      QT 4.8







      qt cross-compilation






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Aug 3 '15 at 22:11









      SagebrushwillySagebrushwilly

      33113




      33113






















          1 Answer
          1






          active

          oldest

          votes


















          8














          For QT4



          The following steps are taken from an answer on a post on stack overflow, for building with qt4 if it works make sure to give them an upvote.



          Just use M cross environment (MXE). It takes the pain out of the whole process:





          1. Get it:



            git clone https://github.com/mxe/mxe.git


          2. Install build dependencies



          3. Build Qt for Windows, its dependencies, and the cross-build tools; this will take about an hour on a fast machine with decent Internet access; the download is about 500MB:



            cd mxe && make qt



          4. Go to the directory of your app and add the cross-build tools to the PATH environment variable:



            export PATH=<mxe root>/usr/bin:$PATH


            Run the Qt Makefile generator tool then build:



            <mxe root>/usr/i686-pc-mingw32/qt/bin/qmake && make



          5. You should find the binary in the ./release directory:



            wine release/foo.exe



          Some notes:



          Use the master branch of the MXE repository; it appears to get a lot more love from the development team.



          The output is a 32-bit static binary, which will work well on 64-bit Windows.



          For QT5



          The following steps are taken from an answer on a post on stack overflow, for building with qt5 if it works make sure to give them an upvote.



          Here are the full instructions:





          1. Get it:



            git clone https://github.com/mxe/mxe.git


          2. Install build dependencies



          3. Build Qt 5 for Windows:



            cd mxe && make qtbase


            This will first build its dependencies and the cross-build tools; It should take less than an hour on a fast machine with decent Internet access.



            Due to the new modular nature of Qt 5, various major Qt components are now in different tarballs. The one selected above, qtbase, should give you enough functionality to run ordinary GUI apps, which is all I needed for my own (smallish) app.



            If you want to build all of Qt 5 instead, you'll need to run make qt5 (instead of make qtbase). Note that it will take a lot longer to complete, so be sure that you need the extra functionality.




          4. Get to the directory of your app, and run the Qt Makefile generator tool:



            <mxe root>/usr/bin/i686-w64-mingw32.static-qmake-qt5



          5. Build your project:



            make



          6. You should find the binary in the ./release directory:



            wine release/foo.exe



          Some notes:



          This was tested on my 64-bit Debian 8, and on Windows of course.



          The output is a 32-bit static executable, which will work well on 64-bit Windows.



          If you want a 64-bit executable, build Qt with:



          make MXE_TARGETS=x86_64-w64-mingw32.static qtbase


          The default MXE_TARGETS value is i686-w64-mingw32.static.






          share|improve this answer

























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "89"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f656219%2fbuilding-a-windows-executable-in-qt-on-a-linux-system%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            8














            For QT4



            The following steps are taken from an answer on a post on stack overflow, for building with qt4 if it works make sure to give them an upvote.



            Just use M cross environment (MXE). It takes the pain out of the whole process:





            1. Get it:



              git clone https://github.com/mxe/mxe.git


            2. Install build dependencies



            3. Build Qt for Windows, its dependencies, and the cross-build tools; this will take about an hour on a fast machine with decent Internet access; the download is about 500MB:



              cd mxe && make qt



            4. Go to the directory of your app and add the cross-build tools to the PATH environment variable:



              export PATH=<mxe root>/usr/bin:$PATH


              Run the Qt Makefile generator tool then build:



              <mxe root>/usr/i686-pc-mingw32/qt/bin/qmake && make



            5. You should find the binary in the ./release directory:



              wine release/foo.exe



            Some notes:



            Use the master branch of the MXE repository; it appears to get a lot more love from the development team.



            The output is a 32-bit static binary, which will work well on 64-bit Windows.



            For QT5



            The following steps are taken from an answer on a post on stack overflow, for building with qt5 if it works make sure to give them an upvote.



            Here are the full instructions:





            1. Get it:



              git clone https://github.com/mxe/mxe.git


            2. Install build dependencies



            3. Build Qt 5 for Windows:



              cd mxe && make qtbase


              This will first build its dependencies and the cross-build tools; It should take less than an hour on a fast machine with decent Internet access.



              Due to the new modular nature of Qt 5, various major Qt components are now in different tarballs. The one selected above, qtbase, should give you enough functionality to run ordinary GUI apps, which is all I needed for my own (smallish) app.



              If you want to build all of Qt 5 instead, you'll need to run make qt5 (instead of make qtbase). Note that it will take a lot longer to complete, so be sure that you need the extra functionality.




            4. Get to the directory of your app, and run the Qt Makefile generator tool:



              <mxe root>/usr/bin/i686-w64-mingw32.static-qmake-qt5



            5. Build your project:



              make



            6. You should find the binary in the ./release directory:



              wine release/foo.exe



            Some notes:



            This was tested on my 64-bit Debian 8, and on Windows of course.



            The output is a 32-bit static executable, which will work well on 64-bit Windows.



            If you want a 64-bit executable, build Qt with:



            make MXE_TARGETS=x86_64-w64-mingw32.static qtbase


            The default MXE_TARGETS value is i686-w64-mingw32.static.






            share|improve this answer






























              8














              For QT4



              The following steps are taken from an answer on a post on stack overflow, for building with qt4 if it works make sure to give them an upvote.



              Just use M cross environment (MXE). It takes the pain out of the whole process:





              1. Get it:



                git clone https://github.com/mxe/mxe.git


              2. Install build dependencies



              3. Build Qt for Windows, its dependencies, and the cross-build tools; this will take about an hour on a fast machine with decent Internet access; the download is about 500MB:



                cd mxe && make qt



              4. Go to the directory of your app and add the cross-build tools to the PATH environment variable:



                export PATH=<mxe root>/usr/bin:$PATH


                Run the Qt Makefile generator tool then build:



                <mxe root>/usr/i686-pc-mingw32/qt/bin/qmake && make



              5. You should find the binary in the ./release directory:



                wine release/foo.exe



              Some notes:



              Use the master branch of the MXE repository; it appears to get a lot more love from the development team.



              The output is a 32-bit static binary, which will work well on 64-bit Windows.



              For QT5



              The following steps are taken from an answer on a post on stack overflow, for building with qt5 if it works make sure to give them an upvote.



              Here are the full instructions:





              1. Get it:



                git clone https://github.com/mxe/mxe.git


              2. Install build dependencies



              3. Build Qt 5 for Windows:



                cd mxe && make qtbase


                This will first build its dependencies and the cross-build tools; It should take less than an hour on a fast machine with decent Internet access.



                Due to the new modular nature of Qt 5, various major Qt components are now in different tarballs. The one selected above, qtbase, should give you enough functionality to run ordinary GUI apps, which is all I needed for my own (smallish) app.



                If you want to build all of Qt 5 instead, you'll need to run make qt5 (instead of make qtbase). Note that it will take a lot longer to complete, so be sure that you need the extra functionality.




              4. Get to the directory of your app, and run the Qt Makefile generator tool:



                <mxe root>/usr/bin/i686-w64-mingw32.static-qmake-qt5



              5. Build your project:



                make



              6. You should find the binary in the ./release directory:



                wine release/foo.exe



              Some notes:



              This was tested on my 64-bit Debian 8, and on Windows of course.



              The output is a 32-bit static executable, which will work well on 64-bit Windows.



              If you want a 64-bit executable, build Qt with:



              make MXE_TARGETS=x86_64-w64-mingw32.static qtbase


              The default MXE_TARGETS value is i686-w64-mingw32.static.






              share|improve this answer




























                8












                8








                8







                For QT4



                The following steps are taken from an answer on a post on stack overflow, for building with qt4 if it works make sure to give them an upvote.



                Just use M cross environment (MXE). It takes the pain out of the whole process:





                1. Get it:



                  git clone https://github.com/mxe/mxe.git


                2. Install build dependencies



                3. Build Qt for Windows, its dependencies, and the cross-build tools; this will take about an hour on a fast machine with decent Internet access; the download is about 500MB:



                  cd mxe && make qt



                4. Go to the directory of your app and add the cross-build tools to the PATH environment variable:



                  export PATH=<mxe root>/usr/bin:$PATH


                  Run the Qt Makefile generator tool then build:



                  <mxe root>/usr/i686-pc-mingw32/qt/bin/qmake && make



                5. You should find the binary in the ./release directory:



                  wine release/foo.exe



                Some notes:



                Use the master branch of the MXE repository; it appears to get a lot more love from the development team.



                The output is a 32-bit static binary, which will work well on 64-bit Windows.



                For QT5



                The following steps are taken from an answer on a post on stack overflow, for building with qt5 if it works make sure to give them an upvote.



                Here are the full instructions:





                1. Get it:



                  git clone https://github.com/mxe/mxe.git


                2. Install build dependencies



                3. Build Qt 5 for Windows:



                  cd mxe && make qtbase


                  This will first build its dependencies and the cross-build tools; It should take less than an hour on a fast machine with decent Internet access.



                  Due to the new modular nature of Qt 5, various major Qt components are now in different tarballs. The one selected above, qtbase, should give you enough functionality to run ordinary GUI apps, which is all I needed for my own (smallish) app.



                  If you want to build all of Qt 5 instead, you'll need to run make qt5 (instead of make qtbase). Note that it will take a lot longer to complete, so be sure that you need the extra functionality.




                4. Get to the directory of your app, and run the Qt Makefile generator tool:



                  <mxe root>/usr/bin/i686-w64-mingw32.static-qmake-qt5



                5. Build your project:



                  make



                6. You should find the binary in the ./release directory:



                  wine release/foo.exe



                Some notes:



                This was tested on my 64-bit Debian 8, and on Windows of course.



                The output is a 32-bit static executable, which will work well on 64-bit Windows.



                If you want a 64-bit executable, build Qt with:



                make MXE_TARGETS=x86_64-w64-mingw32.static qtbase


                The default MXE_TARGETS value is i686-w64-mingw32.static.






                share|improve this answer















                For QT4



                The following steps are taken from an answer on a post on stack overflow, for building with qt4 if it works make sure to give them an upvote.



                Just use M cross environment (MXE). It takes the pain out of the whole process:





                1. Get it:



                  git clone https://github.com/mxe/mxe.git


                2. Install build dependencies



                3. Build Qt for Windows, its dependencies, and the cross-build tools; this will take about an hour on a fast machine with decent Internet access; the download is about 500MB:



                  cd mxe && make qt



                4. Go to the directory of your app and add the cross-build tools to the PATH environment variable:



                  export PATH=<mxe root>/usr/bin:$PATH


                  Run the Qt Makefile generator tool then build:



                  <mxe root>/usr/i686-pc-mingw32/qt/bin/qmake && make



                5. You should find the binary in the ./release directory:



                  wine release/foo.exe



                Some notes:



                Use the master branch of the MXE repository; it appears to get a lot more love from the development team.



                The output is a 32-bit static binary, which will work well on 64-bit Windows.



                For QT5



                The following steps are taken from an answer on a post on stack overflow, for building with qt5 if it works make sure to give them an upvote.



                Here are the full instructions:





                1. Get it:



                  git clone https://github.com/mxe/mxe.git


                2. Install build dependencies



                3. Build Qt 5 for Windows:



                  cd mxe && make qtbase


                  This will first build its dependencies and the cross-build tools; It should take less than an hour on a fast machine with decent Internet access.



                  Due to the new modular nature of Qt 5, various major Qt components are now in different tarballs. The one selected above, qtbase, should give you enough functionality to run ordinary GUI apps, which is all I needed for my own (smallish) app.



                  If you want to build all of Qt 5 instead, you'll need to run make qt5 (instead of make qtbase). Note that it will take a lot longer to complete, so be sure that you need the extra functionality.




                4. Get to the directory of your app, and run the Qt Makefile generator tool:



                  <mxe root>/usr/bin/i686-w64-mingw32.static-qmake-qt5



                5. Build your project:



                  make



                6. You should find the binary in the ./release directory:



                  wine release/foo.exe



                Some notes:



                This was tested on my 64-bit Debian 8, and on Windows of course.



                The output is a 32-bit static executable, which will work well on 64-bit Windows.



                If you want a 64-bit executable, build Qt with:



                make MXE_TARGETS=x86_64-w64-mingw32.static qtbase


                The default MXE_TARGETS value is i686-w64-mingw32.static.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited May 23 '17 at 12:39









                Community

                1




                1










                answered Aug 4 '15 at 7:11









                Mark KirbyMark Kirby

                14k146298




                14k146298






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Ask Ubuntu!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f656219%2fbuilding-a-windows-executable-in-qt-on-a-linux-system%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    How to reconfigure Docker Trusted Registry 2.x.x to use CEPH FS mount instead of NFS and other traditional...

                    is 'sed' thread safe

                    How to make a Squid Proxy server?