67

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.

mins
  • 6,478
  • 12
  • 56
  • 75
Farley
  • 1,160
  • 1
  • 10
  • 17
  • can you post a minimal example? and the compiler you're using (I assume clang++)? – vsoftco Apr 09 '15 at 03:58
  • A workaround is to touch an empty __debug in the corresponding folder but the side effect hard to say. – Farley Apr 09 '15 at 04:04
  • 1
    `#include <__debug> int main(){} ` works for me (compiling with `clang++ test.cpp`), I just upgraded to 10.10.3 – vsoftco Apr 09 '15 at 04:05
  • After updating the Command Line Tools, there is no __debug in the directory. Do you update the Command Line Tools 6.3 too? /Library/Developer/CommandLineTools/usr/include/c++/v1/__debug – Farley Apr 09 '15 at 04:11
  • I don't have the `__debug` either, however the minimal program I posted compiles fine. And yes, I updated the command line tools too. – vsoftco Apr 09 '15 at 04:13
  • That is strange because the same error remains for compiling your simple program on my machine. The __debug may be somewhere else and for some reason it's missing on my system. How could that be? I'm pretty sure there was no interruptions during the updates.... – Farley Apr 09 '15 at 04:17
  • Recently updated to 10.10.3 and Command Line Tools 6.3 and I'm getting `fatal error: '__debug' file not found` as well. I've tried reinstalling Command Line Tools to no avail. To test: `echo $'#include <__debug>\nint main() {}' | clang++ -x c++ -` – gurglet Apr 09 '15 at 09:29
  • I have a clean OS X 10.10.3 install plus the most recent version of Command Line Tools for Xcode 6.3. <__debug> header is indeed missing, so it looks like a bug of the Command Line Tools for Xcode 6.3. – Wildcat Apr 09 '15 at 18:15
  • Just adding the search term Theano. Theno theano theano. Theano is a python library that was broken by the upgrade to 6.3, and the solution to this is the solution to that. – Peter Apr 12 '15 at 13:11

5 Answers5

60

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!

gismo141
  • 884
  • 7
  • 11
  • 1
    Fix or not, it works and it made my afternoon! Thanx. – Mikael Roos Apr 09 '15 at 15:13
  • Great link! I also noticed some open source package compilation may fail with the update of 6.3 such as the valgrind. – Farley Apr 09 '15 at 18:53
  • Well I wasn't able to compile PCL programs anymore ;) so this morning after upgrading: I hated myself :) – gismo141 Apr 09 '15 at 21:20
  • 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. – Wildcat Apr 10 '15 at 18:12
  • 3
    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. – Roy Iacob Apr 11 '15 at 01:15
  • Worked for me too. Make sure you get the correct version posted above (I accidentally downloaded the latest one at first). – Tintin81 Apr 12 '15 at 18:21
  • Same here as for what @Tintin81says. Thanks, gismo141. – mamachanko Apr 13 '15 at 07:17
  • OMG! Thank you! I spent the whole day trying to figure this out. I downgraded the Commandlinetools and everything worked again! :) – Paola Cerioli Apr 13 '15 at 23:46
  • 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? – Dennis Apr 16 '15 at 16:59
  • Apple will likely rev the toolchain soon, so rather than rolling back, @jwu's fix below seems better. – cbowns Apr 16 '15 at 17:26
  • The linker failure is a separate issue; please file a bug at https://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. – Flash Sheridan Apr 22 '15 at 18:05
  • 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`. – Wildcat Apr 23 '15 at 16:15
  • Thanks for your feedback @Wildcat! You were right - after calling it the right way there was no problem at all! Thank you! – gismo141 Apr 23 '15 at 17:12
  • 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. – tblznbits Apr 25 '15 at 02:21
38

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
Dennis
  • 56,821
  • 26
  • 143
  • 139
jwu
  • 381
  • 2
  • 4
  • 1
    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 – ffurrer Apr 15 '15 at 11:38
  • You can also try using the debug header from the [LLVM 3.6 repo](http://reviews.llvm.org/diffusion/L/browse/libcxx/tags/RELEASE_360/final/include/__debug). This is what Xcode 6.3 is based on. – jwu Apr 17 '15 at 07:06
  • 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 Apr 17 '15 at 07:38
  • 1
    Here is the [public bug tracker](http://openradar.appspot.com/radar?id=6405426379751424) and the [release notes](https://developer.apple.com/library/ios/releasenotes/DeveloperTools/RN-Xcode/Chapters/xc6_release_notes.html) in case you want to follow along with any fixes apple has in store. – jwu Apr 17 '15 at 07:38
  • Adding the file did not work for me. Produced 4 errors of: `string:663:13: error: use of undeclared identifier '_LIBCPP_ASSERT'` – Mankka Apr 17 '15 at 08:57
  • 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. – jwu Apr 22 '15 at 07:06
8

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.

Daniel Frey
  • 55,810
  • 13
  • 122
  • 180
6

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

Flash Sheridan
  • 1,671
  • 1
  • 14
  • 14
1

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

zstolar
  • 461
  • 1
  • 4
  • 9