【发布时间】:2015-10-27 01:00:36
【问题描述】:
我最近将我的 Mac OSX 从 Yosemite 升级到 El Capitan 并将 Xcode 更新到 v7.1。升级后发现我的C++应用程序因为找不到头文件而无法编译:
../../src/dir/sysArea.h:39:10: fatal error: 'boost/thread/tss.hpp' file not found
#include <boost/thread/tss.hpp>
clang 调用是这样的:
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
我使用查找器搜索了我的 Macintosh,但文件 tss.hpp 似乎不再存在。如何将我的应用程序移植到 El Capitan,Boost 的 tss.hpp 的替代品是什么?我尝试将我的 Boost 版本从之前的 v1.53 更新到最新的 v1.58,但没有任何影响,我在编译时遇到了同样的错误。
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
我的 C++03 应用程序包含 tss.hpp,以便它可以使用 thread_specific_ptr<> 功能:
static boost::thread_specific_ptr<Botan::AutoSeeded_RNG> _rng;
用于线程本地存储(例如,每个线程都有自己的静态变量版本。)
finder 并没有到处搜索(如果搜索就好了),我在 /usr/local/include 下确实有 tss.hpp。
我尝试将 -stdlib=libc++ 和 -stdlib=libstdc++ 添加到 clang 调用中,但都没有让编译器在 /usr/local/include 中查找 Boost 标头。除了硬编码-I/user/local/include 之外,还有哪些编译器标志会指示它查看那里?
请注意,clang 说 thread_local 不能作为 discussed here 使用。
【问题讨论】:
-
另外,你愿意迁移到 c++11 吗?然后你可以放弃提升,只使用
thread_local -
@donkopotamus 是的,我正在考虑使用
thread_local的选项,但仍然希望问题得到解答。 -
您能否确认
boost/thread/tss.hpp不在/usr/local/include中...如果不是,那似乎是brew安装的问题。 (我不使用brew)。如果是,那么您的编译器标志是否正确? -
@donkopotamus 是的,发现者没有在那里搜索,并误导我认为他们不再存在。如何指示编译器在 El Capitan 中查看
/usr/local/include。请注意,这在 Yosemite 中不是问题。 -
将
-I/usr/local/include添加到您的编译器标志中,您需要将适当的-L标志添加到链接阶段。
标签: c++ boost porting c++03 osx-elcapitan