在我目前从事的 Xcode 项目中,我使用 C++11 和 Apple LLVM 4.2 (clang) 编译器,并使用 libstdc++ 作为我的标准库,因为我使用的库 (NTL) 不是用 libc++ 编译的,并且所以我必须使用 libstdc++。
编写以下代码时:
#include <regex>
int main()
{
return 0;
}
它不编译,说:
'regex' file not found
所以我不能在我的 libstdc++ 中使用任何 C++11 库(也试过了<mutex>
)<thread>
。
我尝试采用的另一个方法是NTL
使用 cc 和 libc++ 重新编译,但这似乎没什么用。以下是产生的一些错误:
../include/NTL/config.h:57:5: error: expected value in expression
#if
^
../include/NTL/config.h:88:5: error: expected value in expression
#if
^
../include/NTL/config.h:95:5: error: expected value in expression
#if
^
../include/NTL/config.h:112:5: error: expected value in expression
#if
^
../include/NTL/config.h:120:5: error: expected value in expression
#if
^
../include/NTL/config.h:143:7: error: expected value in expression
#elif
^
../include/NTL/config.h:168:5: error: expected value in expression
#if
^
../include/NTL/config.h:189:5: error: expected value in expression
#if
^
../include/NTL/config.h:208:5: error: expected value in expression
#if
^
../include/NTL/config.h:226:5: error: expected value in expression
#if
^
../include/NTL/config.h:248:5: error: expected value in expression
#if
^
../include/NTL/config.h:260:5: error: expected value in expression
#if
^
../include/NTL/config.h:273:5: error: expected value in expression
#if
^
../include/NTL/config.h:289:5: error: expected value in expression
#if
^
../include/NTL/config.h:309:5: error: expected value in expression
#if
^
../include/NTL/config.h:326:7: error: expected value in expression
#elif
^
In file included from FFT.c:3:
In file included from ../include/NTL/FFT.h:6:
In file included from ../include/NTL/ZZ.h:19:
../include/NTL/tools.h:21:10: fatal error: 'iostream.h' file not found`
似乎配置标头以某种方式“损坏”并且 libc++ 没有<iostream.h>
旧的 c++ 标头。因此,重新编译NTL
对我来说有点麻烦。
那么,我该如何解决呢?如何在我的项目中仍然使用 libstdc++ 并拥有 C++11 库?如果这有帮助,我已经用 brew 安装了 g++-4.8。有没有办法将clang使用的libstdc++映射到新的?