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. Building & Running Qt programs on QtCreator for MacBook Pro M1
Forum Updated to NodeBB v4.3 + New Features

Building & Running Qt programs on QtCreator for MacBook Pro M1

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 2 Posters 3.0k Views 1 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.
  • K Offline
    K Offline
    kostasch
    wrote on last edited by
    #1

    Hello,

    I managed to install QtCreator for MacOS and load a Qt project on it. However, when I try to Build the project I get the following error :
    "ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)"

    After searching about the problem, I ended up on : https://bugreports.qt.io/browse/QTBUG-85279

    and tried to build 6.0 and 5.15 versions (using git checkout) using the options that are mentioned there. However, I never got it to build because of various errors.

    Has anyone been able to build & run any program using QtCreator on MacOS with M1 processor?

    Thanks in advance.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Has anyone been able to build & run any program using QtCreator on MacOS with M1 processor?

      Yes, for me it "just works". Had no problem compiling or running any apps. I'm using Qt 5.15.2 and newest Xcode. And Rosetta2 of course. Apps compiled on M1 also work on other macs.

      (Z(:^

      K 1 Reply Last reply
      0
      • sierdzioS sierdzio

        Has anyone been able to build & run any program using QtCreator on MacOS with M1 processor?

        Yes, for me it "just works". Had no problem compiling or running any apps. I'm using Qt 5.15.2 and newest Xcode. And Rosetta2 of course. Apps compiled on M1 also work on other macs.

        K Offline
        K Offline
        kostasch
        wrote on last edited by
        #3

        @sierdzio It was my fault. I used libelf library (after installing it manually) and this is causing the problem because it was not developed for macOS I suppose.

        What's interesting is that I managed to compile a program using libelf manually using clang but QtCreator somehow fails to compile the same program (yields the error mentioned above).

        To make this straight : I coded a test program using libelf library to check if libelf links correctly with my programs. I compiled my program using clang ...
        -L/path/to/libelf_library -lelf -I/path/to/libelf_headers and it worked.

        But QtCreator fails to compile it, have you encountered something like this?

        1 Reply Last reply
        1
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          No I haven't, but I have not tried anything with libelf. How did you compile it in Qt Creator, what's your project file?

          (Z(:^

          K 1 Reply Last reply
          0
          • sierdzioS sierdzio

            No I haven't, but I have not tried anything with libelf. How did you compile it in Qt Creator, what's your project file?

            K Offline
            K Offline
            kostasch
            wrote on last edited by kostasch
            #5

            @sierdzio I re-built Qt (5.15) and Qt Creator from sources like this reddit post suggested : https://www.reddit.com/r/QtFramework/comments/ll58wg/how_to_build_qt_creator_for_macos_arm64_a_guide/

            After building everything successfully, I ran QtCreator w/o using any other libraries. Just QApplication.

            However, I still got :
            "warning: ignoring file release/qtbase/lib/QtCore.framework/QtCore, building for macOS-x86_64 but attempting to link with file built for macOS-arm64"

            which was the reason for the "error : undefined symbols for x86_64".

            My .pro file contains the following :

            QT -= gui
            
            CONFIG += QMAKE_APPLE_DEVICE_ARCHS=arm64
            CONFIG += c++11 console sdk_no_version_check
            CONFIG -= app_bundle
            
            SOURCES += \
                    main.cpp
            
            # Default rules for deployment.
            qnx: target.path = /tmp/$${TARGET}/bin
            else: unix:!android: target.path = /opt/$${TARGET}/bin
            !isEmpty(target.path): INSTALLS += target
            

            The project contains just a main.cpp file with the following code :

            #include <QCoreApplication>
            
            int main(int argc, char *argv[])
            {
              QCoreApplication a(argc, argv);
            
              return a.exec();
            }
            

            Finally, my kit configuration is the following :
            https://ibb.co/vmn6t2V

            1 Reply Last reply
            0
            • sierdzioS Offline
              sierdzioS Offline
              sierdzio
              Moderators
              wrote on last edited by
              #6

              @kostasch said in Building & Running Qt programs on QtCreator for MacBook Pro M1:

              CONFIG += QMAKE_APPLE_DEVICE_ARCHS=arm64

              Ah so you are directly requesting arm64 architecture. I am building for x86_64.

              As the bug you've linked to suggests, building specifically for arm64 is not yet ready.

              (Z(:^

              K 1 Reply Last reply
              0
              • sierdzioS sierdzio

                @kostasch said in Building & Running Qt programs on QtCreator for MacBook Pro M1:

                CONFIG += QMAKE_APPLE_DEVICE_ARCHS=arm64

                Ah so you are directly requesting arm64 architecture. I am building for x86_64.

                As the bug you've linked to suggests, building specifically for arm64 is not yet ready.

                K Offline
                K Offline
                kostasch
                wrote on last edited by
                #7

                @sierdzio Even without this CONFIG parameter, it still doesn't work.
                How did you get it to build and run a project?

                1 Reply Last reply
                0
                • sierdzioS Offline
                  sierdzioS Offline
                  sierdzio
                  Moderators
                  wrote on last edited by
                  #8

                  I really did nothing :D The same code which works on Linux, Windows and older macs simply worked for me on M1.

                  (Z(:^

                  K 1 Reply Last reply
                  0
                  • sierdzioS sierdzio

                    I really did nothing :D The same code which works on Linux, Windows and older macs simply worked for me on M1.

                    K Offline
                    K Offline
                    kostasch
                    wrote on last edited by
                    #9

                    @sierdzio Ah, okay then. I guess I will wait for the official support.
                    Thanks!

                    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