Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Cross-compile Qt 5.9.1 with MSVC 2017 x64 to x86 fails with linker error
QtWS25 Last Chance

Cross-compile Qt 5.9.1 with MSVC 2017 x64 to x86 fails with linker error

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
5.9.1cross compilex86x64
13 Posts 4 Posters 8.8k 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.
  • V Offline
    V Offline
    v5exp4
    wrote on last edited by
    #3

    AFAIK they are. Still I would like to know what happens, it should be feasible to cross compile Qt from x64 to x86.

    1 Reply Last reply
    0
    • V Offline
      V Offline
      v5exp4
      wrote on last edited by
      #4

      So far it seems, no matter what I do (tried passing -device-options, creating own mkspec for specific 32 bit platform, not to use the common msvc mkspec), after configuration my target architecture is set to x86_64 in qtbase/mkspecs/qconfig.pri. Also at the configuration phase when running config tests I get the message that target platform is x86_64.

      What parameters shall I pass to the configure script to make it change? Has anyone tried this before?

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

        Hi,

        Did you try the x86 Native Tools Command Prompt ?

        Also, how did you setup your build environment for the cross-compilation ?

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

        V 2 Replies Last reply
        2
        • V Offline
          V Offline
          v5exp4
          wrote on last edited by v5exp4
          #6

          Hi,

          Thanks for the response!

          I might have a conceptional misunderstanding. I have tried to set MSVC to x64 to x86 cross-compilation, thus ran vcvars.bat amd64_x86. Isn't the x86 Native Tool Command Prompt (i.e. vcvars.bat x86) for native compilation? Meaning that compile on a x86 host to a x86 target? I aim to build on a x64 host to a x86 machine, which means that all my build tools (e.g. qmake) shall be compiled with a native compiler (because I would run them on my 64-bit host), and all the libs I intend to deploy should be compiled to x86.

          (So basically this is how I set my build environment for CC, running visual studio 2017's configuration script - vcvars.bat)

          jsulmJ 1 Reply Last reply
          0
          • V v5exp4

            Hi,

            Thanks for the response!

            I might have a conceptional misunderstanding. I have tried to set MSVC to x64 to x86 cross-compilation, thus ran vcvars.bat amd64_x86. Isn't the x86 Native Tool Command Prompt (i.e. vcvars.bat x86) for native compilation? Meaning that compile on a x86 host to a x86 target? I aim to build on a x64 host to a x86 machine, which means that all my build tools (e.g. qmake) shall be compiled with a native compiler (because I would run them on my 64-bit host), and all the libs I intend to deploy should be compiled to x86.

            (So basically this is how I set my build environment for CC, running visual studio 2017's configuration script - vcvars.bat)

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

            @v5exp4 There is no need to compile the build tools for x86 as x86_64 can execute x86 binaries.

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

            V 1 Reply Last reply
            0
            • jsulmJ jsulm

              @v5exp4 There is no need to compile the build tools for x86 as x86_64 can execute x86 binaries.

              V Offline
              V Offline
              v5exp4
              wrote on last edited by v5exp4
              #8

              @jsulm Yes, that is true. However if I set my environment to a x86 toolchain (either amd64_x86 cross or even native x86) it would throw me the same error, meaning that the linker is targeting x64 for my build tools, such as qmake, while my libraries are compiled to x86. Therefore I get the architecture mismatch mentioned in my original post.

              It seems that during the configuration of the Qt build it tries and discovers the host platform and sets the target for qmake automatically. Which is fine for me, as I would run qmake on x64 however I need my libraries built for x86 targets.

              1 Reply Last reply
              0
              • SGaistS SGaist

                Hi,

                Did you try the x86 Native Tools Command Prompt ?

                Also, how did you setup your build environment for the cross-compilation ?

                V Offline
                V Offline
                v5exp4
                wrote on last edited by
                #9

                @SGaist I tried using the native tools, but it would throw me the very same error.

                1 Reply Last reply
                0
                • SGaistS SGaist

                  Hi,

                  Did you try the x86 Native Tools Command Prompt ?

                  Also, how did you setup your build environment for the cross-compilation ?

                  V Offline
                  V Offline
                  v5exp4
                  wrote on last edited by
                  #10

                  @SGaist
                  I was wrong before. I could properly compile with x86 native tools on x64. The problem was that after previous configurations the cache files were not cleaned properly and setup was stuck for x64 target.

                  So the problem is worked around, however I still expect that it should be possible to compile with the x64_x86 cross tools. When I run the configure.bat script, the target architecture is listed as x64 (should be i386). Seems that no matter what I do, what flags I try to pass, this is unchanged. Seems that this value is somehow derived from the compiler itself and I am unable to set it to i386 instead of x64.

                  Does anybody know what flags are necessary to be passed to actually set the target architecture to i386?

                  Thank you for all your help,
                  Balazs

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

                    Is it me or does it look like QTBUG-43457 ?

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

                    V 1 Reply Last reply
                    2
                    • SGaistS SGaist

                      Is it me or does it look like QTBUG-43457 ?

                      V Offline
                      V Offline
                      v5exp4
                      wrote on last edited by
                      #12

                      @SGaist Exactly! Thank you for finding it. I will apply the patch, see how it goes and mark this as solved.

                      1 Reply Last reply
                      0
                      • V Offline
                        V Offline
                        v5exp4
                        wrote on last edited by
                        #13

                        I have checked the source code of the qmakeevaluator and the changes are present in version 5.9.1, still it does not recognize the platform. Even if I try to hardcode to the qmake evaluator the following:

                        vars[ProKey("QMAKE_TARGET.arch")] = ProString("x86");

                        It does not change a thing, still tries to link qmake to x64.

                        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