为什么安装Xcode命令行工具会改变'gcc --version'报告的内容 [英] Why did installing Xcode command line tools change what 'gcc --version' reports
问题描述
最近,我通过AppStore将OS 10.9上的Xcode更新到5.0.1版。在我看来,这个更新也更新了命令行工具,例如运行 gcc --version
生成的
<$ p $配置文件:--prefix = / Applications / Xcode.app / Contents / Developer / usr --with-gxx-include-dir = / Applications / Xcode.app / Contents / Developer / Platforms / MacOSX.platform / Developer / SDKs / MacOSX10.9.sdk / usr / include / c ++ / 4.2.1
Apple LLVM 5.0版(clang-500.2.79)(基于LLVM 3.3svn)
目标:x86_64-apple-darwin13.0.0
线程模型:posix
然而 SE在此处的表明情况并非如此,命令行工具需要单独下载和安装。我做到了这一点,并以相同的工具版本结束,但有细微的差异。例如,现在正在运行 gcc --version
产生
gcc - -version
配置:--prefix = / Applications / Xcode.app /目录/ Developer / usr --with-gxx-include-dir = / usr / include / c ++ / 4.2.1
Apple LLVM 5.0版(clang-500.2.79)(基于LLVM 3.3svn)
目标:x86_64-apple-darwin13.0.0
线程模型:posix
这是事情应该如何工作的吗?这是否代表当前Xcode命令行工具的预期行为,还是它通过直接下载安装的特性? 。通过AppStore与Xcode一起安装;如果甚至可能的话)?
从 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/的变化有什么意义MacOSX10.9.sdk / usr / include / c ++ / 4.2.1
至 / usr / include / c ++ / 4.2.1
?
我会用列表来组织我的答案,这样您就可以得到完整的图片,您的主要问题的答案会在最后结束列表项: 鉴于现在SDK已经捆绑并组织在一个目录结构中在XCode.app包内部,你注意到的gxx-include-dir中的变化是由于现在/ usr / include仅仅是一个软链接,现在已经到了特定包含的适当位置: $ ls -l / usr / include
gcc
和 g ++
的同义词已被保留下来,是非常向后兼容的GCC,没有理由不这样做。
xcode-select --install
,然后按照说明操作。
最后一点,不一定是坏事, xcode-select(1)
命令现在可以用来管理acti ve SDK。
我希望这会让那些困惑的人澄清一些事情,因为所有这些(相当大的)变化都是以完全沉默的方式以经典的苹果时尚推出的。
Recently I updated Xcode on OS 10.9 to version 5.0.1 through the AppStore. It appeared to me that this update also updated command line tools, for example running gcc --version
produced
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix
However answers here on SE indicate that this is not the case and that command line tools need to be downloaded and installed separately. I did this and ended up with the same tool versions, but with subtle differences. For example, now running running gcc --version
produces
gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix
Is this how things are supposed to work — does this represent the expected behavior for current Xcode command line tools or is it peculiar to an installation via direct download (vs. installing along with Xcode through the AppStore; if that's even possible)?
And what's the significance of the change from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1
to /usr/include/c++/4.2.1
?
I'll structure my answer with a list so that you get the full picture, the answer to your main question being concluded in the last list item:
- Since Mavericks, the default compiler suite has been Clang/LLVM instead of GNU GCC. Synonyms for
gcc
andg++
that point to Clang and Clang++ respectively have been kept in order to preserve backwards compatibility and since Clang is very much backwards compatible with GCC, there's no reason not to do so. - Since XCode 6 I think, XCode automatically bundles the command line developer tools in the main install and .app bundle for XCode. Same goes for default frameworks and toolkits. Full command line development is still not fully operational at this point, just enabled XCode development.
- However, in order to successfully do development at the command line one has to execute
xcode-select --install
in the Terminal app and follow the instructions. Given that the SDK's are now bundled and organized in a directory structure inside XCode.app bundle, the change in gxx-include-dir you noticed is due to the fact that now, /usr/include is merely a soft link now to the proper place for the specific includes:
$ls -l /usr/include
lrwxr-xr-x 1 root wheel 112 Feb 2 19:08 /usr/include -> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/
The last point, is not necessarily a bad thing and xcode-select(1)
command can now be used to manage the active SDK.
I hope this clarifies things a bit for those confused, since all these (quite big) changes were rolled out in classic Apple fashion, in complete and utter silence.
这篇关于为什么安装Xcode命令行工具会改变'gcc --version'报告的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!