Missing C++ header <__debug> after updating OSX Command Line Tools 6.3

14,987

Solution 1

Downgrade the Command Line Tools to 6.2 via Apple's Developer Download Page.

Be careful to download the correct version for your OS X:

  • OS X 10.10 commandlinetoolsosx10.10forxcode6.2.dmg
  • OS X 10.9 commandlinetoolsosx10.9forxcode6.2.dmg

This works because the inclusion of __debug is conditionally guarded as follows in Command Line Tools 6.2 but not in 6.3.

#ifdef _LIBCPP_DEBUG
#   include <__debug>
#else
#   define _LIBCPP_ASSERT(x, m) ((void)0)
#endif

In my opinion this is the safest way, because:

  1. You don't compromise your toolchain
  2. You can easily upgrade via the App Store when Apple fixes the issue
  3. If you add a file manually you have to delete it later or more problems could occur

Update - 21.04.2015

Problem fixed by Apple. After installing Command Line Tools 6.3.1 everything works as expected!

Solution 2

Temporarily create the missing __debug file where _LIBCPP_ASSERT is defined as in Command Line Tools 6.2 for OS X.

echo '#define _LIBCPP_ASSERT(x, m) ((void)0)' | sudo tee -a /Library/Developer/CommandLineTools/usr/include/c++/v1/__debug > /dev/null

Remove the temporary file after the build finished.

sudo rm /Library/Developer/CommandLineTools/usr/include/c++/v1/__debug

Solution 3

Warning!!! This is a hack, use at your own risk!!! This work-around is only meant as a temporary fix until Apple provides an update to the command-line tools.

OK, here we go: Create the file yourself and put the following content into it:

#ifndef _LIBCPP_ASSERT
#define _LIBCPP_ASSERT(...) ((void)0)
#endif

This seems to work for me, but it is certainly not the right thing to do. Make sure the file is located at the right place /Library/Developer/CommandLineTools/usr/include/c++/v1/__debug with the right owner/permissions.

Solution 4

This is now fixed in Command Line Tools 6.3.1, available from https://developer.apple.com/downloads. The update should appear automatically in your App Store Updates (though it’s labelled as 6.3, not 6.3.1). Apologies for the inconvenience, and thanks very much for reporting the issue.

Earlier: A workaround which worked for me in a simple case was setting a minimum of OS X 10.8 or earlier, with “-mmacosx-version-min=10.8”.

Solution 5

I followed @Flash Sheridan advice and got my CLT working again (git, ruby, brew...) - I used "Command Line Tools (OS X 10.10) for Xcode 6.3.1".

Share:
14,987
Farley
Author by

Farley

Updated on June 17, 2022

Comments

  • Farley
    Farley almost 2 years

    After updating to Command Line Tools 6.3 from the App Store, programs including <vector> or <iterator> which internally include <__debug> will cause file not found error as follows. The cpp is nothing interesting but includes in one of the included headers.

    c++ -O3 -I/Users/farleylai/Documents/dev/git/ESMS/Optimizer/../StreamIt/src/cluster/headers -L/Users/farleylai/Documents/dev/git/ESMS/Optimizer/../StreamIt/build/binaries/clusterStaticLibrary /Users/farleylai/Documents/dev/git/ESMS/Optimizer/build/StreamIt/FIR/511/512/combined_threads.cpp -o streamit -lcluster -lpthread -lstdc++
    In file included from /Users/farleylai/Documents/dev/git/ESMS/Optimizer/build/StreamIt/FIR/511/512/combined_threads.cpp:9:
    In file included from /Users/farleylai/Documents/dev/git/ESMS/Optimizer/../StreamIt/src/cluster/headers/node_server.h:22:
    In file included from /Users/farleylai/Documents/dev/git/ESMS/Optimizer/../StreamIt/src/cluster/headers/thread_info.h:20:
    In file included from /Users/farleylai/Documents/dev/git/ESMS/Optimizer/../StreamIt/src/cluster/headers/connection_info.h:19:
    /Users/farleylai/Documents/dev/git/ESMS/Optimizer/../StreamIt/src/cluster/headers/socket_holder.h:43:25: warning: delete called on 'mysocket' that is abstract but has non-virtual destructor
          [-Wdelete-non-virtual-dtor]
        if (!is_mem_socket) delete sock;
                            ^
    In file included from /Users/farleylai/Documents/dev/git/ESMS/Optimizer/build/StreamIt/FIR/511/512/combined_threads.cpp:9:
    In file included from /Users/farleylai/Documents/dev/git/ESMS/Optimizer/../StreamIt/src/cluster/headers/node_server.h:22:
    In file included from /Users/farleylai/Documents/dev/git/ESMS/Optimizer/../StreamIt/src/cluster/headers/thread_info.h:26:
    In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/vector:265:
    In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/__bit_reference:15:
    /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/algorithm:641:10: fatal error: '__debug' file not found
    #include <__debug>
             ^
    

    Any ideas to fix this? I don't expect to specify any additional C++ flags.

    Thanks.

    PS: MacBook pro on OSX 10.10.3

    Updates:

    The issue is verified by Apple on their developer's forum. In Command Line Tools 6.2, the inclusion of __debug is conditionally guarded as follows but not in 6.3.

    #ifdef _LIBCPP_DEBUG
    #   include <__debug>
    #else
    #   define _LIBCPP_ASSERT(x, m) ((void)0)
    #endif
    

    And libcxx people talked about removing the guards of __debug here. It feels like __debug never exists on OSX.

  • Mikael Roos
    Mikael Roos about 9 years
    Fix or not, it works and it made my afternoon! Thanx.
  • Farley
    Farley about 9 years
    Great link! I also noticed some open source package compilation may fail with the update of 6.3 such as the valgrind.
  • gismo141
    gismo141 about 9 years
    Well I wasn't able to compile PCL programs anymore ;) so this morning after upgrading: I hated myself :)
  • Wildcat
    Wildcat about 9 years
    I wouldn't call it a fix, since by installing previous version of Command Line Tools you simply downgrade them. For instance, Command Line Tools for Xcode 6.3 are based on LLVM 3.6svn, while Command Line Tools for Xcode 6.2 are based on LLVM 3.5svn.
  • Roy Iacob
    Roy Iacob about 9 years
    This required no additional action other than installing the dmg (no uninstalling). Might be worth noting in case anyone is reluctant to try this solution.
  • Tintin81
    Tintin81 about 9 years
    Worked for me too. Make sure you get the correct version posted above (I accidentally downloaded the latest one at first).
  • mamachanko
    mamachanko about 9 years
    Same here as for what @Tintin81says. Thanks, gismo141.
  • Paola Cerioli
    Paola Cerioli about 9 years
    OMG! Thank you! I spent the whole day trying to figure this out. I downgraded the Commandlinetools and everything worked again! :)
  • ffurrer
    ffurrer about 9 years
    Did work for parts of my files but new errors like error: no type named 'allocator' in namespace 'std' occured. So I downgraded commandlinetools to 6.2
  • Dennis
    Dennis about 9 years
    This answer in its current state is as good as "it works because magic". For example, why doesn't it work with 6.3 but (supposedly) does work with 6.2?
  • cbowns
    cbowns about 9 years
    Apple will likely rev the toolchain soon, so rather than rolling back, @jwu's fix below seems better.
  • jwu
    jwu about 9 years
    You can also try using the debug header from the LLVM 3.6 repo. This is what Xcode 6.3 is based on.
  • jwu
    jwu about 9 years
    And if that does not work, there is mention of this workaround on GitHub, which requires a full Xcode install: sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
  • jwu
    jwu about 9 years
    Here is the public bug tracker and the release notes in case you want to follow along with any fixes apple has in store.
  • Mankka
    Mankka about 9 years
    Adding the file did not work for me. Produced 4 errors of: string:663:13: error: use of undeclared identifier '_LIBCPP_ASSERT'
  • jwu
    jwu about 9 years
    So, as the other post hinted at, apple has added the missing __debug file with the Command Line Tools 6.3.1 update. That file seems to be the same as the one from the LLVM 3.6 repo mentioned above.
  • Viorel Stoianov
    Viorel Stoianov about 9 years
    The linker failure is a separate issue; please file a bug at bugreport.apple.com, and include the output with -v. Please also include all the source you’re including, or a reduced case which reproduces the problem, since the linkage failure doesn’t happen with my test cases.
  • Wildcat
    Wildcat about 9 years
    Problem is fixed by Apple, and I think it is now OP who does the things in the wrong way. In particular, one should invoke clang C++ compiler by either clang++ or as clang -x c++ -lc++ but not just as clang.
  • gismo141
    gismo141 about 9 years
    Thanks for your feedback @Wildcat! You were right - after calling it the right way there was no problem at all! Thank you!
  • tblznbits
    tblznbits about 9 years
    For anyone who finds this question, @gismo141's update is spot on. You just need to update your command line tools and it'll work just fine.