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. Qt 5.5.1 OS X 10.11 Static linkage Qt Multimedia

Qt 5.5.1 OS X 10.11 Static linkage Qt Multimedia

Scheduled Pinned Locked Moved Solved Installation and Deployment
mac osqtmultimediastatic build
21 Posts 4 Posters 9.5k 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.
  • Ivan KolesnikovI Offline
    Ivan KolesnikovI Offline
    Ivan Kolesnikov
    wrote on last edited by Ivan Kolesnikov
    #1

    I need to static compile an application in OS X. This application is works and statically compiles in Windows. And I can compile it non-statically via Qt Creator in OS X. It's a simple console script wich use the qtmultimedia module.
    OS X version is 10.11, Xcode 7.2.

    I try the following steps:

    1. Install Qt through the Qt installer.
    2. Build Qt statically from Source:
      2.1. ./configure -prefix /Users/User/qtstatic -static -debug-and-release -opensource -nomake tests -nomake examples -skip declarative -skip quick1 -skip quickcontrols -qt-libpng -qt-libjpeg -no-opengl -qt-zlib
      2.2. make -j 4
      2.3. For build the Qt Multimedia module do this steps (https://forum.qt.io/topic/30781/solved-qt5-deploying-an-application-on-windows-static-linking/7):
    • cd qtmultimedia
    • Users/User/Qt5.5.1/5.5/Src/qtbase/bin/qmake /Users/User/Qt5.5.1/5.5/Src/qtmultimedia/qtmultimedia.pro -o Makefile
    • cd ../
    • make
      2.4. sudo make install
    1. Try compile an application:
      3.1. cd applicationDir
      3.2. make clean
      3.3. /Users/User/qtstatic/bin/qmake -config release
      3.4. make
      Then I get the following error message:
      "Undefined symbols for architecture x86_64:
      "AVFVideoRendererControl::staticMetaObject", referenced from:
      AVFMediaPlayerService::releaseControl(QMediaControl*) in libqavfmediaplayer.a(avfmediaplayerservice.o)
      "AVFVideoRendererControl::AVFVideoRendererControl(QObject*)", referenced from:
      AVFMediaPlayerService::requestControl(char const*) in libqavfmediaplayer.a(avfmediaplayerservice.o)
      ld: symbol(s) not found for architecture x86_64
      clang: error: linker command failed with exit code 1 (use -v to see invocation)
      make: *** [MetadataExtractor] Error 1

    Please see .pro file of this application:
    QT += core multimedia widgets
    #QMAKE_LFLAGS += -static -static-libgcc
    QT -= gui
    TARGET = MetadataExtractor
    CONFIG += console
    CONFIG -= app_bundle
    #QMAKE_LFLAGS_RELEASE += -static -static-libgcc
    TEMPLATE = app
    SOURCES += main.cpp
    extractor.cpp
    HEADERS +=
    extractor.h

    Please advise how I can fix this issue.

    Ivan KolesnikovI 1 Reply Last reply
    0
    • Ivan KolesnikovI Ivan Kolesnikov

      I need to static compile an application in OS X. This application is works and statically compiles in Windows. And I can compile it non-statically via Qt Creator in OS X. It's a simple console script wich use the qtmultimedia module.
      OS X version is 10.11, Xcode 7.2.

      I try the following steps:

      1. Install Qt through the Qt installer.
      2. Build Qt statically from Source:
        2.1. ./configure -prefix /Users/User/qtstatic -static -debug-and-release -opensource -nomake tests -nomake examples -skip declarative -skip quick1 -skip quickcontrols -qt-libpng -qt-libjpeg -no-opengl -qt-zlib
        2.2. make -j 4
        2.3. For build the Qt Multimedia module do this steps (https://forum.qt.io/topic/30781/solved-qt5-deploying-an-application-on-windows-static-linking/7):
      • cd qtmultimedia
      • Users/User/Qt5.5.1/5.5/Src/qtbase/bin/qmake /Users/User/Qt5.5.1/5.5/Src/qtmultimedia/qtmultimedia.pro -o Makefile
      • cd ../
      • make
        2.4. sudo make install
      1. Try compile an application:
        3.1. cd applicationDir
        3.2. make clean
        3.3. /Users/User/qtstatic/bin/qmake -config release
        3.4. make
        Then I get the following error message:
        "Undefined symbols for architecture x86_64:
        "AVFVideoRendererControl::staticMetaObject", referenced from:
        AVFMediaPlayerService::releaseControl(QMediaControl*) in libqavfmediaplayer.a(avfmediaplayerservice.o)
        "AVFVideoRendererControl::AVFVideoRendererControl(QObject*)", referenced from:
        AVFMediaPlayerService::requestControl(char const*) in libqavfmediaplayer.a(avfmediaplayerservice.o)
        ld: symbol(s) not found for architecture x86_64
        clang: error: linker command failed with exit code 1 (use -v to see invocation)
        make: *** [MetadataExtractor] Error 1

      Please see .pro file of this application:
      QT += core multimedia widgets
      #QMAKE_LFLAGS += -static -static-libgcc
      QT -= gui
      TARGET = MetadataExtractor
      CONFIG += console
      CONFIG -= app_bundle
      #QMAKE_LFLAGS_RELEASE += -static -static-libgcc
      TEMPLATE = app
      SOURCES += main.cpp
      extractor.cpp
      HEADERS +=
      extractor.h

      Please advise how I can fix this issue.

      Ivan KolesnikovI Offline
      Ivan KolesnikovI Offline
      Ivan Kolesnikov
      wrote on last edited by
      #2

      @Ivan-Kolesnikov up

      1 Reply Last reply
      0
      • T Offline
        T Offline
        Tyras
        wrote on last edited by
        #3

        You can't build static linked binaries in OSX.

        Apple doesn't provide static versions of their libs, so, static compilation always fail.

        You can try what they say in the link below, but, for me, didn't worked.

        https://developer.apple.com/library/mac/qa/qa1118/_index.html

        When a coder says that it's impossible to do something, he's actually feeling too lazy to do it.

        kshegunovK 1 Reply Last reply
        1
        • T Tyras

          You can't build static linked binaries in OSX.

          Apple doesn't provide static versions of their libs, so, static compilation always fail.

          You can try what they say in the link below, but, for me, didn't worked.

          https://developer.apple.com/library/mac/qa/qa1118/_index.html

          kshegunovK Away
          kshegunovK Away
          kshegunov
          Moderators
          wrote on last edited by
          #4

          @Tyras said:

          Apple doesn't provide static versions of their libs

          As far as I know no one does, except linux, but you'd need the full source of the system libraries, which is a bit excessive and unnecessary.

          @Ivan-Kolesnikov
          It's a linker error, so you have to investigate that. While I don't work on macs, you seem to link with default options against the OS-wide Qt binaries, which probably are dynamic libraries. I can't see

          CONFIG += static
          

          in your project.

          Kind regards.

          Read and abide by the Qt Code of Conduct

          T 1 Reply Last reply
          1
          • kshegunovK kshegunov

            @Tyras said:

            Apple doesn't provide static versions of their libs

            As far as I know no one does, except linux, but you'd need the full source of the system libraries, which is a bit excessive and unnecessary.

            @Ivan-Kolesnikov
            It's a linker error, so you have to investigate that. While I don't work on macs, you seem to link with default options against the OS-wide Qt binaries, which probably are dynamic libraries. I can't see

            CONFIG += static
            

            in your project.

            Kind regards.

            T Offline
            T Offline
            Tyras
            wrote on last edited by
            #5

            @kshegunov

            I'm not sure, but looks like windows provide them with MSVC, since static builds works even without the source. in OSX, Even if you do as you say and put CONFIG += static, the build will fail, saying that it can't find the crt0 library, unless its a library project. You can confirm this from apple in the link I provided.

            When a coder says that it's impossible to do something, he's actually feeling too lazy to do it.

            kshegunovK 1 Reply Last reply
            0
            • T Tyras

              @kshegunov

              I'm not sure, but looks like windows provide them with MSVC, since static builds works even without the source. in OSX, Even if you do as you say and put CONFIG += static, the build will fail, saying that it can't find the crt0 library, unless its a library project. You can confirm this from apple in the link I provided.

              kshegunovK Away
              kshegunovK Away
              kshegunov
              Moderators
              wrote on last edited by
              #6

              @Tyras said:

              I'm not sure, but looks like windows provide them with MSVC

              It certainly doesn't, how else MS could ask you for a lot of money for windows?

              the build will fail, saying that it can't find the crt0 library, unless its a library project.

              It's possible, however I don't see a reason for anyone to want to link the runtime statically.

              You can confirm this from apple in the link I provided.

              I can't really confirm it, because I neither have a mac, nor I'm going to have. What I can do is to wait for some of the mac users to jump at the chance to make me look silly ;)

              Kind regards.

              Read and abide by the Qt Code of Conduct

              1 Reply Last reply
              0
              • T Offline
                T Offline
                Tyras
                wrote on last edited by
                #7

                @kshegunov

                It certainly doesn't, how else MS could ask you for a lot of money for windows?

                AFAIK, static libraries are binaries, and they can dynamically link (and require) to the system libraries blunded in Windows. Why couldn't they charge for it?

                I can't really confirm it, because I neither have a mac, nor I'm going to have. What I can do is to wait for some of the mac users to jump at the chance to make me look silly ;)

                Well, You can, since in the link (that is from Apple's Technical Q&A), says:

                Apple does not support statically linked binaries on Mac OS X. A statically linked binary assumes binary compatibility at the kernel system call interface, and we do not make any guarantees on that front. Rather, we strive to ensure binary compatibility in each dynamically linked system library and framework.

                When a coder says that it's impossible to do something, he's actually feeling too lazy to do it.

                kshegunovK 1 Reply Last reply
                0
                • T Tyras

                  @kshegunov

                  It certainly doesn't, how else MS could ask you for a lot of money for windows?

                  AFAIK, static libraries are binaries, and they can dynamically link (and require) to the system libraries blunded in Windows. Why couldn't they charge for it?

                  I can't really confirm it, because I neither have a mac, nor I'm going to have. What I can do is to wait for some of the mac users to jump at the chance to make me look silly ;)

                  Well, You can, since in the link (that is from Apple's Technical Q&A), says:

                  Apple does not support statically linked binaries on Mac OS X. A statically linked binary assumes binary compatibility at the kernel system call interface, and we do not make any guarantees on that front. Rather, we strive to ensure binary compatibility in each dynamically linked system library and framework.

                  kshegunovK Away
                  kshegunovK Away
                  kshegunov
                  Moderators
                  wrote on last edited by kshegunov
                  #8

                  @Tyras said:

                  AFAIK, static libraries are binaries

                  Everything built is a binary, a static library, a dynamic library, an executable, you name it. However you're not linking the system libraries statically, and that's exactly the point of having an SDK.

                  A statically linked binary assumes binary compatibility at the kernel system call interface

                  Meaning you can't statically link the system libraries, the frameworks and the like, as they make direct calls to the kernel interface.

                  Rather, we strive to ensure binary compatibility in each dynamically linked system library and framework.

                  So you can link the system libraries and frameworks dynamically. This doesn't in principle mean that Qt can't be built statically and/or your applications can't link Qt statically.

                  Kind regards.

                  Read and abide by the Qt Code of Conduct

                  1 Reply Last reply
                  0
                  • T Offline
                    T Offline
                    Tyras
                    wrote on last edited by
                    #9

                    @kshegunov

                    So you can link the system libraries and frameworks dynamically. This doesn't in principle mean that Qt can't be built statically and/or your applications can't link Qt statically.

                    The Applications can link QT statically, yes. The problem won't be when linking to QT, since, as I said before, it is possible to create static libraries in OSX, and therefore, create a static build of QT libraries.

                    Talking from experience, when you try to build an static executable in OSX (with or without QT), it will try to link to a static version of crt0, that is not provided. So, unless you build yourself a static version of crt0 for OSX (as said in the link I provided), It will fail.

                    When a coder says that it's impossible to do something, he's actually feeling too lazy to do it.

                    kshegunovK 1 Reply Last reply
                    0
                    • T Tyras

                      @kshegunov

                      So you can link the system libraries and frameworks dynamically. This doesn't in principle mean that Qt can't be built statically and/or your applications can't link Qt statically.

                      The Applications can link QT statically, yes. The problem won't be when linking to QT, since, as I said before, it is possible to create static libraries in OSX, and therefore, create a static build of QT libraries.

                      Talking from experience, when you try to build an static executable in OSX (with or without QT), it will try to link to a static version of crt0, that is not provided. So, unless you build yourself a static version of crt0 for OSX (as said in the link I provided), It will fail.

                      kshegunovK Away
                      kshegunovK Away
                      kshegunov
                      Moderators
                      wrote on last edited by kshegunov
                      #10

                      @Tyras said:

                      static executable

                      I have no notion of what that is, sorry. Maybe @SGaist will explain to me, if he's feeling benevolent, what Apple considers a "static binary".

                      Talking from experience, when you try to build an static executable in OSX (with or without QT), it will try to link to a static version of crt0, that is not provided. So, unless you build yourself a static version of crt0 for OSX (as said in the link I provided), It will fail.

                      I'll just take your word for it, since I have no basis for comparison. Note that I'm not so much arguing, as trying to understand "why" would that be. :)

                      Kind regards.

                      Read and abide by the Qt Code of Conduct

                      1 Reply Last reply
                      0
                      • T Offline
                        T Offline
                        Tyras
                        wrote on last edited by Tyras
                        #11

                        @kshegunov

                        I understand "static executable" (or, as Apple calls it, "static binary") as an executable file that requires no libraries other than those blunded by default with the OS.

                        I'll just take your word for it, since I have no basis for comparison. Note that I'm not so much arguing, as trying to understand "why" would that be. :)

                        Trust me, I'm still trying to understand why they did it this way.

                        When a coder says that it's impossible to do something, he's actually feeling too lazy to do it.

                        kshegunovK 1 Reply Last reply
                        0
                        • T Tyras

                          @kshegunov

                          I understand "static executable" (or, as Apple calls it, "static binary") as an executable file that requires no libraries other than those blunded by default with the OS.

                          I'll just take your word for it, since I have no basis for comparison. Note that I'm not so much arguing, as trying to understand "why" would that be. :)

                          Trust me, I'm still trying to understand why they did it this way.

                          kshegunovK Away
                          kshegunovK Away
                          kshegunov
                          Moderators
                          wrote on last edited by kshegunov
                          #12

                          @Tyras

                          I understand "static executable" (or, as Apple calls it, "static binary") as an executable file that requires no libraries other than those blunded by default with the OS.

                          I don't understand it like this. However I believe @Ivan-Kolesnikov is not linking the needed dynamic libraries from the OS X framework(s) - the foundation framework or however that is called ... he has to have LIBS += -lavfoundation or something along this lines in his application.

                          Edit:
                          Maybe something like:

                          LIBS += -framework AppKit -framework QuartzCore -framework QTKit
                          

                          which I saw in a repo diff update somewhere.

                          Kind regards.

                          Read and abide by the Qt Code of Conduct

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

                            Hi,

                            The symbols missing come from the Qt multimedia plugin based on AV Foundation. There are some special considerations for plugins when using Qt statically. These are described here.

                            On Windows you can have a fully static application. Microsoft does provide their runtime in both configurations but recommend to use the shared version to allow update to be done to them (as in security update). Going the full static way is possible but requires to modify Qt's mkspec to link against the static runtime and thus a full rebuild.

                            On OS X, it's indeed not possible to have 100% static application. You will always link dynamically to the system frameworks. Note that if you want to use the App Store, having a statically linked application is likely to get your application rejected. IIRC it's part of Apple's guideline to use dynamic libraries and framework.

                            So all in all, you can use a static Qt while still having dynamic dependencies.

                            On an important side note: static linking has licensing implications.

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

                            kshegunovK 1 Reply Last reply
                            2
                            • SGaistS SGaist

                              Hi,

                              The symbols missing come from the Qt multimedia plugin based on AV Foundation. There are some special considerations for plugins when using Qt statically. These are described here.

                              On Windows you can have a fully static application. Microsoft does provide their runtime in both configurations but recommend to use the shared version to allow update to be done to them (as in security update). Going the full static way is possible but requires to modify Qt's mkspec to link against the static runtime and thus a full rebuild.

                              On OS X, it's indeed not possible to have 100% static application. You will always link dynamically to the system frameworks. Note that if you want to use the App Store, having a statically linked application is likely to get your application rejected. IIRC it's part of Apple's guideline to use dynamic libraries and framework.

                              So all in all, you can use a static Qt while still having dynamic dependencies.

                              On an important side note: static linking has licensing implications.

                              kshegunovK Away
                              kshegunovK Away
                              kshegunov
                              Moderators
                              wrote on last edited by kshegunov
                              #14

                              @SGaist said:

                              On Windows you can have a fully static application. Microsoft does provide their runtime in both configurations

                              This is news to me, but in any case I'm dynamic-linking enthusiast ...

                              On OS X, it's indeed not possible to have 100% static application. You will always link dynamically to the system frameworks.

                              So there's no problem as long as you link dynamically against the runtime, which is what I was trying to convince @Tyras. :)

                              Read and abide by the Qt Code of Conduct

                              T 1 Reply Last reply
                              0
                              • kshegunovK kshegunov

                                @SGaist said:

                                On Windows you can have a fully static application. Microsoft does provide their runtime in both configurations

                                This is news to me, but in any case I'm dynamic-linking enthusiast ...

                                On OS X, it's indeed not possible to have 100% static application. You will always link dynamically to the system frameworks.

                                So there's no problem as long as you link dynamically against the runtime, which is what I was trying to convince @Tyras. :)

                                T Offline
                                T Offline
                                Tyras
                                wrote on last edited by
                                #15

                                @kshegunov said

                                So there's no problem as long as you link dynamically against the runtime

                                Fair enough, I guess, but that can end up requiring the final user to install such runtimes in the target machine, or to bundle it with the application, what, IMHO, go against the purporse of static linking... but, if that suits the OP, or if the required runtimes are already present on the target, then you're right.

                                When a coder says that it's impossible to do something, he's actually feeling too lazy to do it.

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

                                  What happens usually on Windows is that the runtime is bundled with the application. What can also be done is to run the Microsoft runtime installer as part of the installation of the application.

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

                                  kshegunovK 1 Reply Last reply
                                  2
                                  • SGaistS SGaist

                                    What happens usually on Windows is that the runtime is bundled with the application. What can also be done is to run the Microsoft runtime installer as part of the installation of the application.

                                    kshegunovK Away
                                    kshegunovK Away
                                    kshegunov
                                    Moderators
                                    wrote on last edited by
                                    #17

                                    I, personally, would never consider linking statically the runtime, but that's just me. As it can be seen I was not even aware MS provides static binaries for the runtime ...

                                    What can also be done is to run the Microsoft runtime installer as part of the installation of the application.

                                    This always seemed to me as the best option on any platform, not only on windows.

                                    Read and abide by the Qt Code of Conduct

                                    1 Reply Last reply
                                    1
                                    • T Offline
                                      T Offline
                                      Tyras
                                      wrote on last edited by
                                      #18

                                      What can also be done is to run the Microsoft runtime installer as part of the installation of the application.

                                      @kshegunov said:

                                      This always seemed to me as the best option on any platform, not only on windows.

                                      For applications meant to be installed, I agree completely. But, sometimes, for small applications meant to be run without installation from anywhere, is somewhat of a bother.

                                      When a coder says that it's impossible to do something, he's actually feeling too lazy to do it.

                                      1 Reply Last reply
                                      0
                                      • Ivan KolesnikovI Offline
                                        Ivan KolesnikovI Offline
                                        Ivan Kolesnikov
                                        wrote on last edited by
                                        #19

                                        Thanks to Everyone for replies!

                                        My main task is build this application in OS X and be able to run it in another OS X system without any Qt libraries. No need add this application to the App Store. If I build this application via Qt Creator without any static libraries then I can run executable file on this machine and it works fine, but if I move this executable file on a Mac without Qt then I getting the following error:
                                        "dyld: Library not loaded: @rpath/QtMultimedia.framework/Versions/5/QtMultimedia
                                        Referenced from: /Users/ivan/Downloads/Archive/./MetadataExtractor
                                        Reason: image not found
                                        Trace/BPT trap: 5"

                                        @SGaist I think for solve this issue need only to create Qt Multimedia plugin statically as described here: http://doc.qt.io/qt-5/plugins-howto.html#creating-static-plugins
                                        In Q_IMPORT_PLUGIN(PluginName) PluginName is multimedia.
                                        In Q_INIT_RESOURCE(name) Name is a path to .qrc file for Qt Multimedia plugin
                                        Is this correct ?

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

                                          In that case, why not just use macdeployqt to create the application bundle ?

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

                                          Ivan KolesnikovI 1 Reply Last reply
                                          2

                                          • Login

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