使C编译器在OS X上运行?

时间:2017-01-22 17:08:59

标签: c xcode macos gcc osx-elcapitan

我无法使用XCode 8.2.1在我的Mac OS X 10.11上使用C编译器来正常运行。我安装了最新的XCode并删除了所有现有的gcc二进制文件,但仍然收到以下错误:

-- PCRE: Removing 'configure' log files
-- PCRE: PCRE_WORKING_DIR: /Users/abc/Documents/Slicer/Slicer-SuperBuild-Debug/PCRE-prefix/src/PCRE-build
-- PCRE: sh;/Users/abc/Documents/Slicer/Slicer-SuperBuild-Debug/PCRE-prefix/src/PCRE/configure;--prefix=/Users/abc/Documents/Slicer/Slicer-SuperBuild-Debug/PCRE;--disable-shared
-- PCRE: Errors detected - See below.
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /Users/abc/Documents/Slicer/Slicer-SuperBuild-Debug/PCRE-prefix/src/PCRE/install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking for style of include used by make... GNU
checking for gcc... /Library/Developer/CommandLineTools/usr/bin/cc
checking whether the C compiler works... no
configure: error: in `/Users/abc/Documents/Slicer/Slicer-SuperBuild-Debug/PCRE-prefix/src/PCRE-build':
configure: error: C compiler cannot create executables
CMake Error at /Users/abc/Documents/Slicer/Slicer/CMake/ExternalProjectForNonCMakeProject.cmake:76 (message):
  PCRE: Error in configure step.  See
  /Users/abc/Documents/Slicer/Slicer-SuperBuild-Debug/PCRE_configure_step_output.txt
  and
  /Users/abc/Documents/Slicer/Slicer-SuperBuild-Debug/PCRE_configure_step_error.txt
Call Stack (most recent call first):
  /Users/abc/Documents/Slicer/Slicer-SuperBuild-Debug/PCRE_configure_step.cmake:3 (ExternalProject_Execute)
make[2]: *** [PCRE-prefix/src/PCRE-stamp/PCRE-configure] Error 1
make[1]: *** [CMakeFiles/PCRE.dir/all] Error 2
make: *** [all] Error 2

如何在我的配置上正确使用C编译器?

1 个答案:

答案 0 :(得分:1)

听起来你想从命令行运行C编译器(而不是在Xcode中)。

访问Apple的开发者网站download section并下载Command Line Tools (macOS 10.12) for Xcode 8.2。这可能需要有效的开发者帐户。

直接链接目前为:Command Line Tools