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. QT enable cross-compiling using MinGW (precompiled)
QtWS25 Last Chance

QT enable cross-compiling using MinGW (precompiled)

Scheduled Pinned Locked Moved Unsolved General and Desktop
qtcreatorcompilerscross compilecross platformmingw
6 Posts 4 Posters 5.2k 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.
  • C Offline
    C Offline
    CybeX
    wrote on 12 Nov 2016, 21:07 last edited by
    #1

    Good day all

    I have been searching for a method of cross-compiling for QT-Creator in Linux for sometime now, and I have been having alot of trouble with it.

    Background info

    please note: I am on a Linux machine, and would like to cross compile Windows Apps

    My system:

    • Ubuntu Gnome 16.10
    • QT Creator 4.0.2 (based on QT 5.7)

    I have came across a few SO links, a few blogs with broken instructions, etc and one seeming helpful but dependencies could not be found.

    I have also attempted another compiler MXE and cloned and attempted to build the MXE compiler from the GIT repo, which failed (no solution for the build error - VTK build error)

    I decided to download precompiled MinGW compilers (i686 and x86_x64 versions) from sourceforge

    Issue:

    In QT Creator, adding the compiler is done without an issue, adding the "Kit" and selecting the newly added compiler, an red exclamation gives an error

    The Compiler (x86_windows_msys_pe_64bit) cannot produce code for QT version 5.7.0 GCC 64Bit (x86_linux_generic_elf_64bit)

    This occurs for both 32 + 64 bit compilers.

    K 1 Reply Last reply 12 Nov 2016, 21:21
    0
    • C CybeX
      12 Nov 2016, 21:07

      Good day all

      I have been searching for a method of cross-compiling for QT-Creator in Linux for sometime now, and I have been having alot of trouble with it.

      Background info

      please note: I am on a Linux machine, and would like to cross compile Windows Apps

      My system:

      • Ubuntu Gnome 16.10
      • QT Creator 4.0.2 (based on QT 5.7)

      I have came across a few SO links, a few blogs with broken instructions, etc and one seeming helpful but dependencies could not be found.

      I have also attempted another compiler MXE and cloned and attempted to build the MXE compiler from the GIT repo, which failed (no solution for the build error - VTK build error)

      I decided to download precompiled MinGW compilers (i686 and x86_x64 versions) from sourceforge

      Issue:

      In QT Creator, adding the compiler is done without an issue, adding the "Kit" and selecting the newly added compiler, an red exclamation gives an error

      The Compiler (x86_windows_msys_pe_64bit) cannot produce code for QT version 5.7.0 GCC 64Bit (x86_linux_generic_elf_64bit)

      This occurs for both 32 + 64 bit compilers.

      K Offline
      K Offline
      koahnig
      wrote on 12 Nov 2016, 21:21 last edited by
      #2

      @CybeX

      Hi and welcome to devnet

      Libraries for windows and linux are different. Also when you have a pre-compiled desktop version for linux you cannot use this for an embedded linux. You probably have to compile also Qt libs with your MinGW cross compiler first. Those cross-compiled Qt libs may be combined with any application for are using the same cross-compiler. In your case it Qt creator which is compiled and linked against a special version of Qt libs.

      From the error message you are showing you have installed a linux version which could be used for a linux compile on your desktop. The compiled applications may be deployed to any desktop linux.

      However, you cannot use those compiled libs for anything else than your desktop and the compiler you have chosen.

      Vote the answer(s) that helped you to solve your issue(s)

      C 1 Reply Last reply 13 Nov 2016, 06:29
      1
      • K koahnig
        12 Nov 2016, 21:21

        @CybeX

        Hi and welcome to devnet

        Libraries for windows and linux are different. Also when you have a pre-compiled desktop version for linux you cannot use this for an embedded linux. You probably have to compile also Qt libs with your MinGW cross compiler first. Those cross-compiled Qt libs may be combined with any application for are using the same cross-compiler. In your case it Qt creator which is compiled and linked against a special version of Qt libs.

        From the error message you are showing you have installed a linux version which could be used for a linux compile on your desktop. The compiled applications may be deployed to any desktop linux.

        However, you cannot use those compiled libs for anything else than your desktop and the compiler you have chosen.

        C Offline
        C Offline
        CybeX
        wrote on 13 Nov 2016, 06:29 last edited by
        #3

        @koahnig thank you for the welcome and the response.

        To clarify, I need to "recompile" QT sources/libs for QTCreator using the QTCreator-MinGW or using my downloaded precompiled MinGW compiler?

        aka ( I not only need the compiler allowing for cross-compiling, but also the libs for the "Windows compiler" )

        I am familiar with the compiler, how should I proceed with compiling and adding the libs for the "Windows compiler"

        What I am thinking is pulling the source for the Windows MinGW, but adding the libs to a current version of QT-Creator (my current Linux version) I think i will need some guidance / assistance with.

        Any advice?

        Thank you in advance

        K 1 Reply Last reply 13 Nov 2016, 13:08
        0
        • C CybeX
          13 Nov 2016, 06:29

          @koahnig thank you for the welcome and the response.

          To clarify, I need to "recompile" QT sources/libs for QTCreator using the QTCreator-MinGW or using my downloaded precompiled MinGW compiler?

          aka ( I not only need the compiler allowing for cross-compiling, but also the libs for the "Windows compiler" )

          I am familiar with the compiler, how should I proceed with compiling and adding the libs for the "Windows compiler"

          What I am thinking is pulling the source for the Windows MinGW, but adding the libs to a current version of QT-Creator (my current Linux version) I think i will need some guidance / assistance with.

          Any advice?

          Thank you in advance

          K Offline
          K Offline
          koahnig
          wrote on 13 Nov 2016, 13:08 last edited by
          #4

          @CybeX

          You cannot mix libs compiled for different platform or with different compilers in general.

          You can directly install Qt creator and the Qt libs already precomiled for linux. Alternatively you can precompiled versions for other OS. However, native comilers can compile always only for the OS they "designed" for.

          As you already understand you need a cross-compiler on linux for generation of an executable to be run on windows. Probably if all would be only one file, you simply no longer think about it. You generate hundreds of different .obj using the cross-compiler and link them together. However, you would always use the cross-compiler for generation of those objs when you plan to use this on windows.

          Now libs and dynamic libs are basically nothing else than a bunch of packed and special formatted obj-files. Therefore, it is a good idea to use the same compiler thorughout the same process.

          You use a native linux gcc for instance. It comes already with some basic libs, you do not have to take of of. With this you can compile any source, create libs adn daynamic libs and finally applications. At the end you have an application executable on linux.

          Staying on linux, but you plan to create something for an embedded linux. You take a cross-compiler and do the same thing for your whole source which is not supplied with the embedded compiler. At the end you have an application for embedded linux. At no point you should use something already compiled for your original linux you are working on. Everything shall be specifically compiled for your target.

          If you substitute "embedded linux" with any other OS in the paragraph before, it becomes clear that you need to compile everything from source and you are only able to use only libs already supplied with your cross-compiler.

          Qt creator is an application using some dynamic Qt libs. Therefore, for whatever platform you are compiling Qt creator you have to make sure that you have libraries fitting with your compiler and the target platform.

          Theoretically there is a slight chance that objs and libs compiled on windows with the MinGW on windows are identical with the objs and libs generated with your MinGW cross-compiler on linux. But for sure, I would not bet on this a penny.

          Therefore, my advices. Compile the whole Qt libs with your MinGW cross-compiler and as next step Qt creator with the same cross-compiler.

          Vote the answer(s) that helped you to solve your issue(s)

          1 Reply Last reply
          3
          • A Offline
            A Offline
            ambershark
            wrote on 15 Nov 2016, 02:44 last edited by
            #5

            The way I typically handle this is to have a virtual machine (virtualbox is easy and free for linux) with the target environment so I can build. In your case windows. Then just set up mingw or Qt Creator or Visual Studio and Qt. Build there for your windows based deployments.

            You definitely can not mix libraries and objects from a different platform (i.e. windows) on your linux host platform.

            My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

            M 1 Reply Last reply 15 Nov 2016, 08:22
            1
            • A ambershark
              15 Nov 2016, 02:44

              The way I typically handle this is to have a virtual machine (virtualbox is easy and free for linux) with the target environment so I can build. In your case windows. Then just set up mingw or Qt Creator or Visual Studio and Qt. Build there for your windows based deployments.

              You definitely can not mix libraries and objects from a different platform (i.e. windows) on your linux host platform.

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 15 Nov 2016, 08:22 last edited by
              #6

              I can only second what @ambershark says.
              Using a virtual machine is far less pain than what you are trying.

              1 Reply Last reply
              1

              6/6

              15 Nov 2016, 08:22

              • Login

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