铛:警告:没有这样的sysroot目录:编译LLVM(3.9.0)时'-mmacosx-version-min = 10.5' [英] clang: warning: no such sysroot directory: '-mmacosx-version-min=10.5' on compiling LLVM (3.9.0)

查看:378
本文介绍了铛:警告:没有这样的sysroot目录:编译LLVM(3.9.0)时'-mmacosx-version-min = 10.5'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用GCC在Mac(OsX)上使用CMake(3.6.2)编译LLVM(3.9.0),但是通过以下GCC配置我不知何故出现以下错误

I am compiling LLVM (3.9.0) using CMake (3.6.2) on my Mac (OsX) using GCC, but somehow I am getting the following error with following GCC configuration

Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin


[50%] Building C object projects/compiler-rt/lib/builtins/CMakeFiles/clang_rt.eprintf.dir/eprintf.c.o
clang: warning: no such sysroot directory: '-mmacosx-version-min=10.5'
/Users/Ritzy/llvm_src/llvm-3.9.0.src/projects/compiler-rt/lib/builtins/eprintf.c:14:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
         ^
1 error generated.
make[2]: *** [projects/compiler-rt/lib/builtins/CMakeFiles/clang_rt.eprintf.dir/eprintf.c.o] Error 1
make[1]: *** [projects/compiler-rt/lib/builtins/CMakeFiles/clang_rt.eprintf.dir/all] Error 2
make: *** [all] Error 2

我正在使用以下CMake命令:

I am using following CMake command:

cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR  ..
cmake --build .

我花了数小时来找出问题所在.甚至尝试使用gcc6和clang但徒劳.

I spent hours figuring out what was wrong. Even tried to using gcc6 and clang but in vain.

推荐答案

以下是提供给MacOS/X clang调用的命令行标志的示例:

Here's an example of what the command line flags supplied to a MacOS/X clang invocation might look like:

-pipe -stdlib=libc++ -std=c++11 -stdlib=libc++ -O2 -std=gnu++11 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -mmacosx-version-min=10.7 -Wall -W -fPIC $(DEFINES)

特别注意这一部分:

-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -mmacosx-version-min=10.7

-isysroot告诉编译器在哪里寻找头文件,然后下一个参数-mmacosx-version-min = 10.7告诉它要保持向下兼容的最低MacOS/X版本.

-isysroot tells the compiler where to look for header files, and then the next argument -mmacosx-version-min=10.7 tells it what minimum version of MacOS/X to maintain backwards compatibility with.

在您的情况下,您的CMake调用可能没有为-isysroot参数指定值,而是可能具有以下内容:

In your case, your CMake invocation probably isn't specifying a value for the -isysroot argument, instead it probably has something like this:

-isysroot   -mmacosx-version-min=10.5

... -isysroot标志之后原本打算提供的路径由于某种原因而留为空白(即空字符串),这就是为什么要使用"-mmacosx-version-min = 10.5"的原因解释为在其中查找头文件的路径(当然不起作用).

... where the path that was intended to be supplied after the -isysroot flag has been left blank (i.e. an empty string) for some reason, and that is why "-mmacosx-version-min=10.5" is being interpreted as a path to look for header files in (which of course will not work).

关于为什么将path参数保留为空白,这是您必须自己研究的内容.

As to why the path argument was left blank, that is something you'll have to investigate on your own.

这篇关于铛:警告:没有这样的sysroot目录:编译LLVM(3.9.0)时'-mmacosx-version-min = 10.5'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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