最近我通过AppStore将OS 10上的Xcode更新到5.0.1版。在我看来,此更新还更新了命令行工具,例如运行gcc --version
生成的
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
但是answers here on SE表明情况并非如此,需要单独下载和安装命令行工具。我做到了这一点并最终得到了相同的工具版本,但有微妙的差异。例如,现在正在运行gcc --version
运行
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
这是事情应该如何工作 - 这是否代表了当前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
的变更意义何在?
答案 0 :(得分:3)
我会用一个列表构建我的答案,以便您全面了解,主要问题的答案在最后一个列表项中得出结论:
gcc
和g++
的同义词是为了保持向后兼容性而保留的,因为Clang非常向后兼容GCC,所以没有理由不这样做如此。xcode-select --install
并按照说明操作。鉴于SDK现在已捆绑并组织在XCode.app包内的目录结构中,您注意到的gxx-include-dir中的更改是由于现在/ usr / include仅仅是一个软链接,现在到了特定包含的适当位置:
$ ls -l / usr / include
lrwxr-xr-x 1根轮112 2月2日19:08 / usr / include - > /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include /
最后一点,不一定是坏事,现在可以使用xcode-select(1)
命令来管理活动SDK。
我希望这能为那些困惑的人澄清一些事情,因为所有这些(相当大的)变化都是以经典的Apple风格推出,完全沉默。