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. My app crashes because libc++ is missing.
Qt 6.11 is out! See what's new in the release blog

My app crashes because libc++ is missing.

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 2 Posters 2.5k Views 2 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.
  • StokestackS Offline
    StokestackS Offline
    Stokestack
    wrote on last edited by Stokestack
    #1

    This is under Mac OS. We have an all-CMake-based project.

    If I build my app through Qt Creator, it runs fine. If I build it via a script that calls CMake, it crashes on launch with

    Dyld Error Message:
      dyld: Using shared cache: 1D800E79-F93F-3FEF-9658-B168A649E2E4
    Library not loaded: @rpath/libc++abi.1.dylib
      Referenced from: /Volumes/Cast/Cast.app/Contents/Frameworks/libc++.1.dylib
      Reason: image not found
    

    Looking in the application bundle, I see that the one built by script contains a ton of frameworks under Frameworks, including libc++.1.dylib. The one built by Qt Creator contains none; thus I conclude that Qt Creator is building a statically-linked app and the script is building a dynamic one.

    Obviously this raises some questions. First, why the difference in linkage? The script does this:

    /Applications/CMake.app/Contents/bin/cmake -S $1 -B $BUILD_DIR -GNinja -DCMAKE_BUILD_TYPE:String=${BUILD_TARGET} -DQT_QMAKE_EXECUTABLE:STRING=$QT_DIR/bin/qmake -DCMAKE_PREFIX_PATH:STRING=$QT_DIR -DCMAKE_C_COMPILER:STRING=/usr/bin/gcc -DCMAKE_CXX_COMPILER:STRING=/usr/bin/clang++ -DCMAKE_MAKE_PROGRAM:STRING=$QT_ROOT_DIR/Tools/Ninja/ninja
    

    Looking at the project settings in Qt Creator, I don't see where it specifies static vs. dynamic. I don't see it in the CMakeLists files either; that wouldn't explain why the two builds would vary anyway.

    Also, why is libc++abi.1.dylib missing, when libc++.1.dylib isn't? On my system, these are found under Homebrew's control in usr/local/opt/lib. I have no idea how anything finds them, since there are no symlinks to them under /usr/lib or /usr/local/lib. But I guess that's academic, because they are being found or sourced from elsewhere.

    Thanks for any suggestions on tracking this down!

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

      Hi,

      No, Qt Creator does not create static binaries like that. You would need a static version of Qt and all of the dependencies. Standard library like the C++ runtime is provided by the system.

      You can use for example otool to see exactly what is linked to your executable.

      Your script is likely doing something fishy.

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

      StokestackS 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        No, Qt Creator does not create static binaries like that. You would need a static version of Qt and all of the dependencies. Standard library like the C++ runtime is provided by the system.

        You can use for example otool to see exactly what is linked to your executable.

        Your script is likely doing something fishy.

        StokestackS Offline
        StokestackS Offline
        Stokestack
        wrote on last edited by Stokestack
        #3

        @SGaist Thanks for that info.

        otool -L on the app that runs shows:

        /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1200.3.0)
        

        But why, when that file does not exist?
        The app that crashes shows:

        @executable_path/../Frameworks/libc++.1.dylib (compatibility version 1.0.0, current version 1.0.0)
        

        Every other lib appears to be the same between the two versions, typically

        @rpath/QtQuickControls2.framework/Versions/5/QtQuickControls2 (compatibility version 5.15.0, current version 5.15.2)
        
        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          As I wrote, I don't know what your script does and I suspect there lies the issue.

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

          StokestackS 1 Reply Last reply
          0
          • SGaistS SGaist

            As I wrote, I don't know what your script does and I suspect there lies the issue.

            StokestackS Offline
            StokestackS Offline
            Stokestack
            wrote on last edited by Stokestack
            #5

            @SGaist My question is regarding the otool output for the non-script-built application, the one built by Qt Creator, which runs. It claims that it's linked against

            /usr/lib/libc++.1.dylib

            This file does not exist on my system. So how can it be linked against?

            As a solution to the overall problem, how can I capture the build commands used by Qt Creator so I can use them in place of whatever the script is doing?

            I've tried (BUILD_DIR is passed into the script as a command-line parameter):

            cmake --build $BUILD_DIR --target all
            

            but the result is "Error: could not load cache." In the project build settings I see "Initial CMake parameters," but I don't know how to incorporate those into a scripted invocation.

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

              If memory serves well, it's related to implicit system libs or something like that.

              As for building with Qt Creator, it usually configures the build by pointing to the Qt version of your kit. You can find informations in the CMakefiles.txt.user file. Using ccmake in the build folder should also give you hints.

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

              StokestackS 1 Reply Last reply
              0
              • SGaistS SGaist

                If memory serves well, it's related to implicit system libs or something like that.

                As for building with Qt Creator, it usually configures the build by pointing to the Qt version of your kit. You can find informations in the CMakefiles.txt.user file. Using ccmake in the build folder should also give you hints.

                StokestackS Offline
                StokestackS Offline
                Stokestack
                wrote on last edited by Stokestack
                #7

                @SGaist Thanks.

                Is there a way to see the commands that are issued when you select "Run CMake" in Qt Creator? I tried pasting the contents of the "initial CMake parameters" into a call to cmake in a script, but I get

                CMake Error at lib/lib_camera_match/src/CMakeLists.txt:3 (project):
                  project could not find requested file:
                
                    %{IDE:ResourcePath}/package-manager/auto-setup.cmake
                

                This is followed by tons of warnings like

                ADD_LIBRARY called with SHARED option but the target platform does not
                  support dynamic linking.  Building a STATIC library instead.  This may lead
                  to problems.
                
                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  In the build panel.

                  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

                  • Login

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