clang ++ via homebrew(llvm38) - 系统包含的编译错误

时间:2016-05-19 11:28:36

标签: c++ compiler-errors homebrew clang++

我使用Mac进行开发10.11.3

由于Xcode 7中的Apple llvm仍不支持openmp,我使用自制软件安装了一个更新的llvm / clang,支持openmp via:

$ brew tap homebrew/versions
$ brew install llvm38

然后我有一个非常简单的C ++测试程序,它或多或少是一个标准的openmp测试,我知道应该编译:

#include <iostream>
#include <omp.h>

int main(void)
{
    #pragma omp parallel for
    for( unsigned v = 0; v < 15; ++v )
    {
        printf("thread %d, nthreads %d\n", omp_get_thread_num(), omp_get_num_threads());
    }
}

使用自制软件安装,它建议您需要指定一些额外的东西才能成功编译,特别是从llvm38软件包安装的c ++系统头文件的路径。这将引导我进入以下命令行:

/usr/local/opt/llvm38/bin/clang++-3.8 -fopenmp openmp.cpp -stdlib=libc++ -nostdinc++ -I /usr/local/opt/llvm38/lib/llvm-3.8/include/c++/v1/ -L/usr/local/opt/llvm38/lib/llvm-3.8/lib

但是,运行此命令时,编译失败:

machine:tests me$ /usr/local/opt/llvm38/bin/clang++-3.8 openmp.cpp -stdlib=libc++ -nostdinc++ -I /usr/local/opt/llvm38/lib/llvm-3.8/include/c++/v1/ -L/usr/local/opt/llvm38/lib/llvm-3.8/lib
In file included from openmp.cpp:1:
In file included from /usr/local/opt/llvm38/lib/llvm-3.8/include/c++/v1/iostream:38:
In file included from /usr/local/opt/llvm38/lib/llvm-3.8/include/c++/v1/ios:215:
In file included from /usr/local/opt/llvm38/lib/llvm-3.8/include/c++/v1/iosfwd:90:
/usr/local/opt/llvm38/lib/llvm-3.8/include/c++/v1/wchar.h:119:15: fatal error: 'wchar.h' file not found
#include_next <wchar.h>
              ^
1 error generated.

有谁知道如何解决这个问题并成功编译?

1 个答案:

答案 0 :(得分:4)

根据对原始问题的评论,重新安装/更新Xcode开发人员工具解决了这个问题。

xcode-select --install