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. How to specify target architecture (x86_64 or arm/native) when building qmake project on M1?
QtWS25 Last Chance

How to specify target architecture (x86_64 or arm/native) when building qmake project on M1?

Scheduled Pinned Locked Moved Solved General and Desktop
13 Posts 5 Posters 4.9k 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 Violet Giraffe
    14 Mar 2023, 12:23

    I have a problem with one of my projects, and can't understand why it happens. When built on M1 Mac system, some targets are compiled for x86_64 and some for arm64. Naturally, I get a linker error for arch mismatch. How to specify the desired architecture with qmake and Qt 5.15.2?

    I have other C++ projects that build fine with the same Qt version on the same system.

    J Offline
    J Offline
    jsulm
    Lifetime Qt Champion
    wrote on 14 Mar 2023, 12:56 last edited by
    #2

    @Violet-Giraffe said in How to specify target architecture (x86_64 or arm/native) when building qmake project on M1?:

    How to specify the desired architecture with qmake and Qt 5.15.2?

    By calling qmake from Qt for that architecture.

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

    V 1 Reply Last reply 14 Mar 2023, 12:57
    0
    • J jsulm
      14 Mar 2023, 12:56

      @Violet-Giraffe said in How to specify target architecture (x86_64 or arm/native) when building qmake project on M1?:

      How to specify the desired architecture with qmake and Qt 5.15.2?

      By calling qmake from Qt for that architecture.

      V Offline
      V Offline
      Violet Giraffe
      wrote on 14 Mar 2023, 12:57 last edited by Violet Giraffe
      #3

      @jsulm, I already do, this is Qt 5.15.2 clang_64 (and 5.15.2 only exists for x86_64 on Mac, I believe).

      S 1 Reply Last reply 14 Mar 2023, 20:10
      0
      • V Violet Giraffe
        14 Mar 2023, 12:57

        @jsulm, I already do, this is Qt 5.15.2 clang_64 (and 5.15.2 only exists for x86_64 on Mac, I believe).

        S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 14 Mar 2023, 20:10 last edited by
        #4

        @Violet-Giraffe hi,

        Your other project likely uses libraries that are universal, meaning that they embed both x86_64 and arm64 symbols.

        From memory, Qt 5.15.2 is single arch so you would need to build it yourself for the M1.

        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 14 Mar 2023, 21:50
        0
        • S SGaist
          14 Mar 2023, 20:10

          @Violet-Giraffe hi,

          Your other project likely uses libraries that are universal, meaning that they embed both x86_64 and arm64 symbols.

          From memory, Qt 5.15.2 is single arch so you would need to build it yourself for the M1.

          V Offline
          V Offline
          Violet Giraffe
          wrote on 14 Mar 2023, 21:50 last edited by Violet Giraffe
          #5

          @SGaist, hi, thanks for chiming in! Let me clarify and expand on the question.

          1. I do not want to build for M1/ARM, I only want a pure x86_64 build. So it's no problem that Qt 5.15.2 doesn't support M1.
          2. Some of my own libraries, built by this project, were compiled for M1, and some others for x86_64. It's not even that my M1 binaries cannot be linked with x64 Qt - no, parts of my own project and my own code are being built inconsistently.
          3. The other project is also a C++ qmake subdirs project that uses Qt 5.15.2 and it builds fine, but that didn't help me to figure out why or what the problem is.

          So in short - I don't want to target M1, I want to stop it from targeting M1 and force x86_64 instead.

          V 1 Reply Last reply 14 Mar 2023, 22:59
          0
          • V Violet Giraffe
            14 Mar 2023, 21:50

            @SGaist, hi, thanks for chiming in! Let me clarify and expand on the question.

            1. I do not want to build for M1/ARM, I only want a pure x86_64 build. So it's no problem that Qt 5.15.2 doesn't support M1.
            2. Some of my own libraries, built by this project, were compiled for M1, and some others for x86_64. It's not even that my M1 binaries cannot be linked with x64 Qt - no, parts of my own project and my own code are being built inconsistently.
            3. The other project is also a C++ qmake subdirs project that uses Qt 5.15.2 and it builds fine, but that didn't help me to figure out why or what the problem is.

            So in short - I don't want to target M1, I want to stop it from targeting M1 and force x86_64 instead.

            V Offline
            V Offline
            Violet Giraffe
            wrote on 14 Mar 2023, 22:59 last edited by Violet Giraffe
            #6

            Found it! The required compiler flag is -arch x86_64

            1 Reply Last reply
            1
            • V Violet Giraffe has marked this topic as solved on 14 Mar 2023, 22:59
            • M Offline
              M Offline
              Mehrshad
              wrote on 26 Jul 2023, 22:39 last edited by
              #7

              Excuse me, but I'm still having a similar problem. I did as you said, and ran ./qmake -set arch x86_64, but nothing changed in action. Could you state more specifically what you did to get it fixed?

              More details:
              I'm on an Intel Mac running macOS 12.6.8 and Xcode 14.2. The thing is, I had been using Qt 6.4.2 and Qt Creator 10.0.2, but after a series of Qt-related upgrades, I eventually ended up with Qt 6.5.2 and Qt Creator 11.0.0. Right now, Qt Creator cannot identify any Qt-related classes or identifiers, and I'm getting the same error as you did under Preferences, Kits, Qt Versions. However, projects are being built using the play button.

              J 1 Reply Last reply 27 Jul 2023, 05:31
              0
              • M Mehrshad
                26 Jul 2023, 22:39

                Excuse me, but I'm still having a similar problem. I did as you said, and ran ./qmake -set arch x86_64, but nothing changed in action. Could you state more specifically what you did to get it fixed?

                More details:
                I'm on an Intel Mac running macOS 12.6.8 and Xcode 14.2. The thing is, I had been using Qt 6.4.2 and Qt Creator 10.0.2, but after a series of Qt-related upgrades, I eventually ended up with Qt 6.5.2 and Qt Creator 11.0.0. Right now, Qt Creator cannot identify any Qt-related classes or identifiers, and I'm getting the same error as you did under Preferences, Kits, Qt Versions. However, projects are being built using the play button.

                J Offline
                J Offline
                jsulm
                Lifetime Qt Champion
                wrote on 27 Jul 2023, 05:31 last edited by
                #8

                @Mehrshad said in How to specify target architecture (x86_64 or arm/native) when building qmake project on M1?:

                and I'm getting the same error as you did under Preferences, Kits, Qt Versions

                What error is that?
                What exact Qt version did you install?

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

                M 1 Reply Last reply 27 Jul 2023, 08:12
                0
                • J jsulm
                  27 Jul 2023, 05:31

                  @Mehrshad said in How to specify target architecture (x86_64 or arm/native) when building qmake project on M1?:

                  and I'm getting the same error as you did under Preferences, Kits, Qt Versions

                  What error is that?
                  What exact Qt version did you install?

                  M Offline
                  M Offline
                  Mehrshad
                  wrote on 27 Jul 2023, 08:12 last edited by
                  #9

                  @jsulm I'm sorry. I realize I had replied on the wrong topic. I posted an all-new topic here. I would be more than glad if you could check it out and tell me what you think.

                  1 Reply Last reply
                  0
                  • V Offline
                    V Offline
                    Violet Giraffe
                    wrote on 28 Sept 2023, 14:17 last edited by Violet Giraffe
                    #10

                    For Qt 6.5.3:

                    QMAKE_APPLE_DEVICE_ARCHS = x86_64

                    or QMAKE_APPLE_DEVICE_ARCHS = x86_64 arm64 to create a universal binary, but I have not tested that.

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      Austin K
                      wrote on 3 Aug 2024, 21:59 last edited by
                      #11

                      After creating a 64 bit arm64 binary for m1 on OSX Im getting an error with macdeployqt:

                      mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')

                      (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '~/build/arm64/myapp/Contents/MacOS/QtQuickControls2.framework/Versions/5/QtQuickControls2' (no such file), '~build/arm64/myapp/Contents/Frameworks/QtQuickControls2.framework/Versions/5/QtQuickControls

                      When I look at the actual app it is a 64 bit arm app.

                      Using Qt 5.15.17 - latest and greatest.

                      When running the application in Qt Creator it runs fine. macdeployqt is not creating a correct binary for arm64. However it works fine for x86_64.

                      S 1 Reply Last reply 4 Aug 2024, 08:36
                      0
                      • A Austin K
                        3 Aug 2024, 21:59

                        After creating a 64 bit arm64 binary for m1 on OSX Im getting an error with macdeployqt:

                        mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')

                        (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '~/build/arm64/myapp/Contents/MacOS/QtQuickControls2.framework/Versions/5/QtQuickControls2' (no such file), '~build/arm64/myapp/Contents/Frameworks/QtQuickControls2.framework/Versions/5/QtQuickControls

                        When I look at the actual app it is a 64 bit arm app.

                        Using Qt 5.15.17 - latest and greatest.

                        When running the application in Qt Creator it runs fine. macdeployqt is not creating a correct binary for arm64. However it works fine for x86_64.

                        S Offline
                        S Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on 4 Aug 2024, 08:36 last edited by
                        #12

                        @Austin-K hi and welcome to devnet,

                        AFAIK 5.15.17 is currently a commercial only release so you should check with the Qt Company what is happening with macdeployqt.

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

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          Austin K
                          wrote on 10 Aug 2024, 20:01 last edited by Austin K 8 Oct 2024, 20:01
                          #13

                          @SGaist to I actually was able to fix this.

                          I had to ensure I was using the arm 64-bit version of macdeployqt contained in /macos/

                          ~/Qt5.15.17/5.15.17/clang_64/bin/macdeployqt
                          ~/Qt5.15.17/5.15.17/macos/bin/macdeployqt

                          Its important to use the correct one for the architecture you are building for.

                          Thank you.

                          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