1

I deleted Xcode on Mac OSX Catalina 10.15.7 because I wanted a fresh install. I followed these instructions to remove Xcode. Then I downloaded and installed Xcode 12.1 from developer tools website and also installed command line tools. Now my gcc is failing to compile codes. The gcc I have is old gnu gcc

(base) ANayak-M13:Library anayak$ gcc --version
gcc (GCC) 9.2.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

This is one of the errors I am getting

gcc -o .sconf_temp/sfconftest_0 .sconf_temp/conftest_0.o
ld: library not found for -lSystem
collect2: error: ld returned 1 exit status
scons: Configure: no

checking if gcc works ... no

  Fatal missing dependency
make: *** [clean] Error 1

Any help will be appreciated. Here is another basic code code1.c that is failing.

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char* argv[])
{
    int a;
    return 0;
}

(base) ANayak-M13:Programs anayak$ gcc -o bb code1.c 
In file included from code1.c:1:
/usr/local/lib/gcc/x86_64-apple-darwin19/9.2.0/include-fixed/stdio.h:78:10: fatal error: _stdio.h: No such file or directory
   78 | #include <_stdio.h>
      |          ^~~~~~~~~~
compilation terminated.

I think the Xcode reinstall did something to the /usr/local/ place where gnu gcc is stored.

EDIT 1. It seems after the Xcode and Command Lines Tools upgrade, my /usr/include/ directory is gone.

EDIT 2. Still not working after adding new include path to .bash_profile

export CPATH=/usr/local/include:/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/

(base) ANayak-M13:Programs anayak$ gcc -o bb code1.c 
ld: library not found for -lSystem
collect2: error: ld returned 1 exit status

EDIT3. Apparently this works. But how ? How can I go back to the original way when everything important was in /usr/include and /usr/lib and /usr/bin.

gcc -o bb1 code1.c -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/ -lm

I do have this set up in my .bash_profile but it is completely being ignored export DYLD_LIBRARY_PATH=/usr/local/lib:/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/

Guddu
  • 2,325
  • 2
  • 18
  • 23

0 Answers0