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

C++XcodeMacosStlClang

C++ Problem Overview


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.

C++ Solutions


Solution 1 - C++

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 - C++

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 - C++

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 - C++

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 - C++

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".

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionFarleyView Question on Stackoverflow
Solution 1 - C++gismo141View Answer on Stackoverflow
Solution 2 - C++jwuView Answer on Stackoverflow
Solution 3 - C++Daniel FreyView Answer on Stackoverflow
Solution 4 - C++Flash SheridanView Answer on Stackoverflow
Solution 5 - C++zstolarView Answer on Stackoverflow