Owu*_*aro 5 macos xcode gcc osx-mavericks
我正在使用Mac OS X 10.9(Mavericks).我最近不得不使用CMake和OpenMP库编译代码.所以刚开始我下载的XCode命令行工具用xcode-select --install.这是问题所在:XCode使用的clang编译器没有带来OpenMP.所以我得到gcc-4.9了brew包管理器(GCC有OpenMP库).
它工作正常,但使用它的命令是gcc-4.9和CMake调用cc命令.所以我搜索了一下,发现这/usr/bin/cc是一个象征性的链接/usr/bin/clang.我决定改成它/usr/bin/gcc,但问题是:我不知道这个文件是什么...
它看起来像clang命令文件:如果我没有任何参数运行它,我得到clang错误而不是gcc错误:
$ gcc
clang: error: no input files
$ gcc-4.9
gcc-4.9: fatal error: no input files
compilation terminated.
但它不是一个符号链接......这是一个ls -l命令的结果:
-rwxr-xr-x   1 root   wheel     14224 23 oct 07:40 gcc
(看起来它是在我进行Mavericks升级时创建的)对于g ++而言它完全相同.它是一种铿锵的副本,有不同的名字吗?Apple为什么不使用符号链接?
所以,如果有人知道我是否可以删除这些文件以放置符号链接而没有任何问题(或更好的解决方案),请告诉我!
谢谢 :)
Apple 似乎使用该xcode-select二进制文件重定向了一些常见的开发人员命令行工具。调用一个小型二进制文件而不是符号链接,/usr/bin/gcc该二进制文件可以gcc根据某些环境变量选择不同版本。
从手册页:
xcode-select  controls  the location of the developer directory used by
xcrun(1), xcodebuild(1), cc(1), and other  Xcode  and  BSD  development
tools. This also controls the locations that are searched for by man(1)
for developer tool manpages.
This allows you to easily switch  between  different  versions  of  the
Xcode  tools  and  can be used to update the path to the Xcode if it is
moved after installation.
...
After setting a developer directory, all of the  xcode-select  provided
developer  tool shims (see FILES) will automatically invoke the version
of the tool inside the selected developer directory.
我们可以通过查看二进制文件来确认(这是来自操作系统 10.14.6):
$ otool -tvV /usr/bin/gcc
/usr/bin/gcc:
(__TEXT,__text) section
_main:
0000000100000f77    pushq   %rbp
0000000100000f78    movq    %rsp, %rbp
0000000100000f7b    leal    -0x1(%rdi), %eax
0000000100000f7e    leaq    0x8(%rsi), %rdx
0000000100000f82    leaq    0x29(%rip), %rdi ## literal pool for: "gcc"
0000000100000f89    xorl    %ecx, %ecx
0000000100000f8b    movl    %eax, %esi
0000000100000f8d    callq   0x100000f92 ## symbol stub for: _xcselect_invoke_xcrun
关于该主题的一些文章:
| 归档时间: | 
 | 
| 查看次数: | 903 次 | 
| 最近记录: |