XCode 4.5 'tr1/type_traits' file not found

12,017

Solution 1

I'm guessing you have "C++ Standard Library" set to "libc++". If this is the case, you want <type_traits>, not <tr1/type_traits>. libc++ gives you a C++11 library, whereas libstdc++ (which is also the default in Xcode 4.5) gives you a C++03 library with tr1 support.

If you want, you can auto-detect which library you're using with:

#include <ciso646>  // detect std::lib
#ifdef _LIBCPP_VERSION
// using libc++
#include <type_traits>
#else
// using libstdc++
#include <tr1/type_traits>
#endif

Or in your case perhaps:

#include <ciso646>  // detect std::lib
#ifdef _LIBCPP_VERSION
// using libc++
#define HAVE_TYPE_TRAITS
#else
// using libstdc++
#define HAVE_TR1_TYPE_TRAITS
#endif

Solution 2

This is the command I used to build wxWidgets against libc++ (LLVM C++ Standard Library). Should work on Yosemite and later (at least until Apple breaks everything again):

mkdir build-cocoa-debug
cd build-cocoa-debug
../configure --enable-debug --with-macosx-version-min=10.10
make -j8 #This allows make to use 8 parallel jobs
Share:
12,017
Aranir
Author by

Aranir

iOS Developer and Life Science Student at EPFL

Updated on July 21, 2022

Comments

  • Aranir
    Aranir almost 2 years

    I use the wxwidget library and I have the following problem:

    #if defined(HAVE_TYPE_TRAITS)
        #include <type_traits>
    #elif defined(HAVE_TR1_TYPE_TRAITS)
        #ifdef __VISUALC__
            #include <type_traits>
        #else
            #include <tr1/type_traits>
        #endif
    #endif
    

    here the #include isn't found. I use the Apple LLVM compiler 4.1. (with the c++11 dialect). If I switch to the LLVM GCC 4.2 compiler I have no error there, but the main problem is that all the c++11 inclusions won't work.

    How can I either use the GCC compiler, but with the c++11 standard or make it that the LLVM can find the ?

    any help would be really appreciated.