Search code examples
cxcodemacosgccosx-elcapitan

Making the C compiler work on OS X?


I cannot get the C compiler on my Mac OS X 10.11 with XCode 8.2.1 to run properly. I installed the most recent XCode and removed all the existing gcc binaries, but still am getting the following error:

-- 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

How can I use the C compiler on my configuration properly?


Solution

  • It sounds like you want to run the C compiler from the command line (rather than in Xcode).

    Go to Apple's developer site download section and download the Command Line Tools (macOS 10.12) for Xcode 8.2. This may require an active developer account.

    The direct link is currently: Command Line Tools.