Mac上的libstdc ++中的C ++ 11标准库 [英] C++11 standard libraries in libstdc++ on Mac

查看:1799
本文介绍了Mac上的libstdc ++中的C ++ 11标准库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我目前工作的Xcode项目中,我使用C ++ 11与Apple LLVM 4.2(clang)编译器,并使用libstdc ++作为我的标准库,因为我使用的库(NTL)没有编译使用libc ++,所以我必须使用libstdc ++。



编写以下代码时:

  #include< regex> 
int main()
{
return 0;
}

它不编译,说:



找不到'regex'文件



C ++ 11库与我的libstdc ++(尝试< mutex> < thread> aswell) p>

另一个我试图采取的是用cc和libc ++重新编译 NTL ,但似乎没有什么工作。以下是生成的一些错误:

  ../ include / NTL / config.h:57:5:错误:表达式中的期望值
#if
^
../include/NTL/config.h:88:5:错误:表达式中的期望值
#if
^
../include/NTL/config.h:95:5:错误:表达式中的期望值
#if
^
../include/NTL/ config.h:112:5:error:表达式中的期望值
#if
^
../include/NTL/config.h:120:5:error:表达式中的期望值
#if
^
../include/NTL/config.h:143:7:error:表达式中的期望值
#elif
^
../include/NTL/config.h:168:5:错误:表达式中的期望值
#if
^
../include/NTL/config.h:189: 5:错误:表达式中的期望值
#if
^
../include/NTL/config.h:208:5:错误:表达式中的期望值
#if
^
../include/NTL/config.h:226:5:错误:表达式中的期望值
#if
^
../include/ NTL / config.h:248:5:错误:表达式中的期望值
#if
^
../include/NTL/config.h:260:5:error:expected value在表达式中
#if
^
../include/NTL/config.h:273:5:错误:表达式中的期望值
#if
^
../include/NTL/config.h:289:5:错误:表达式中的期望值
#if
^
../include/NTL/config.h: 309:5:错误:表达式中的期望值
#if
^
../include/NTL/config.h:326:7:错误:表达式中的期望值
#elif
^
在FFT.c中包含的文件中:
在包含在../include/NTL/FFT.h:6中的文件中:
在包含的文件中../include/NTL/ZZ.h:19:
../include/NTL/tools.h:21:10:致命错误:'iostream.h'文件未找到

看起来配置头是以某种方式损坏,libc ++没有< iostream .h> 和旧的c ++标题。因此,重新编译 NTL 对我有点麻烦。



那么,我该如何解决呢?我如何仍然使用libstdc ++我的项目和有C ++ 11库?如果有帮助,我有g ++ - 4.8安装与brew。是否有一种方法将libstdc ++映射到一个新的?

解决方案

如何找到要使用的libstdc ++头。显然,它没有找到它们。我想你想要的标志是 - nostdinc -I / path / to / better / headers



第一部分告诉clang不要使用它的标准头部,第二部分告诉clang在头部寻找头部。


In a Xcode project which I currently work on, I am using C++11 with Apple LLVM 4.2 (clang) compiler, and using libstdc++ as my standard library, because I am using a library (NTL) which was not compiled with libc++ and so I must use libstdc++.

When writing the following code:

#include <regex>
int main()
{
     return 0;
}

It doesn't compile, by saying:

'regex' file not found

And so I can't use any C++11 library with my libstdc++ (Tried <mutex>, <thread> aswell).

Another I tried to take is to recompile NTL with cc and libc++, but that doesn't seem much to work. The following is some of the errors that were produced:

../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`

It seems that the configuration header was somehow "damaged" and that libc++ doesn't have <iostream.h> and old c++ headers. And so, recompiling NTL was a bit of trouble for me.

And so, how can I fix it? How can I still use libstdc++ on my project and have C++11 Libraries? If that helps, I have g++-4.8 installed with brew. Is there a way to map libstdc++ that clang uses to a new one?

解决方案

You'll need to tell your copy of clang how to find the libstdc++ headers that you want to use. Clearly it's not finding them. I think that the flags you want are "-nostdinc -I /path/to/better/headers".

The first part tells clang not to use it's standard headers, and the second one tells it to look for headers "over there".

这篇关于Mac上的libstdc ++中的C ++ 11标准库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆