Search code examples
c++boostportingc++03osx-elcapitan

How to replace boost/thread/tss.hpp on Mac OSX El Capitan?


I recently upgraded my Mac OSX from Yosemite to El Capitan and updated Xcode to v7.1. After the upgrades, I found that my C++ application no longer compiles due to a header file that cannot be found:

../../src/dir/sysArea.h:39:10: fatal error: 'boost/thread/tss.hpp' file not found
#include <boost/thread/tss.hpp>

The clang invocation is like this:

clang -g -std=c++11 -fno-inline -Wall -Werror -Wextra -D_LARGEFILE_SOURCE   \
      -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c                       \
      -o ARCH.darwin_15_i86/debug/file.o file.cpp

I searched my Macintosh using the finder and the file tss.hpp no longer appears to be present. How do I port my application to El Capitan, what is the replacement of Boost's tss.hpp? I tried updating my Boost version from the prior v1.53 to the latest v1.58, but it had no impact, I get the same error when compiling.

export PATH=/usr/local/bin:$PATH
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
sudo chmod o+w /usr/local/opt /usr/local/include /usr/local/lib
brew unlink boost
brew install boost
sudo chmod o-w /usr/local/opt /usr/local/include /usr/local/lib

My C++03 application is including tss.hpp so that it can use the thread_specific_ptr<> feature:

static boost::thread_specific_ptr<Botan::AutoSeeded_RNG> _rng;

for thread local storage (e.g. each thread gets its own version of the static variable.)


The finder was not searching everywhere (would be nice if it did), I do have tss.hpp under /usr/local/include.

I tried adding -stdlib=libc++ and -stdlib=libstdc++ to the clang invocation, but neither got the complier to look in /usr/local/include for the Boost headers. What compiler flags will instruct it to look there other than hardcoding -I/user/local/include?

Note that clang says thread_local is not available as discussed here.


Solution

  • Doing xcode-select --install as per this answer, seems to have told clang to look in the /usr/local/include directory for headers and resolves the issue.