1

Really need help in this one. When I try to compile using cc, it shows

 -bash: /usr/bin/cc: No such file or directory

but all the necessary files cc,gcc,c++ are present in the /usr/bin directory. I tried to install gcc-multilib package after which I'm getting this error. Need to fix it asap as it runs some important programs. when i did : update-alternatives --list cc , it showed /usr/bin/gcc. I then tried, update-alternatives --set cc /usr/bin/gcc, it gave update-alternatives: warning: forcing reinstallation of alternative /usr/bin/gcc because link group cc is broken. update-alternatives: warning: not replacing /usr/bin/cc with a link.

sree127
  • 421
  • 3
  • 9
  • 25
  • Some notes: That last error seems to indicate that a `/usr/bin/cc` was installed / manually moved from outside the package manager process... – Gert van den Berg Jan 07 '21 at 15:43

1 Answers1

2

/usr/bin/cc should be a symbolic link on Ubuntu.

Check that its destination is valid with update-alternatives --list cc.

update-alternatives --set cc /usr/bin/gcc (as root, sudo should work) should fix it if /usr/bin/gcc is a valid executable.

Gert van den Berg
  • 2,448
  • 31
  • 41
  • when i did : update-alternatives --list cc , it showed '/usr/bin/gcc '. And when i did update-alternatives --set cc /usr/bin/gcc , it gave :- update-alternatives: warning: forcing reinstallation of alternative /usr/bin/gcc because link group cc is broken. update-alternatives: warning: not replacing /usr/bin/cc with a link. – sree127 Nov 20 '12 at 08:00
  • 1
    Run `ls -l /usr/bin/cc`. Was GCC installed from the package manager? – Gert van den Berg Nov 20 '12 at 12:02
  • `$ sudo update-alternatives --list cc update-alternatives: error: no alternatives for cc` – Mona Jalal Jan 07 '21 at 03:08
  • @MonaJalal Is the `gcc` package installed? (And are you on Ubuntu? Other distributions might do this differently) (I just checked and that is still the setup if GCC is installed on 18.04 and 20.04 (I only had LTS versions to check on)) – Gert van den Berg Jan 07 '21 at 15:40
  • @GertvandenBerg yes I am on Ubuntu and GCC is installed. – Mona Jalal Jan 07 '21 at 18:52
  • 1
    @MonaJalal Hmm... `update-alternative` creates the links intially (with the `--install` option, it might be that that did not run when the package for GCC was installed... There should be log entries in `/var/log/alternatives.log` (It might be that the `build-essentials` package pulls in some more stuff that sets this up) – Gert van den Berg Jan 07 '21 at 19:11
  • @GertvandenBerg could you please have a look at my question here https://stackoverflow.com/questions/65618513/cmake-error-at-cuda-compile-1-generated-batch-norm-layer-cu-o-release-cmake-afte ? thank you – Mona Jalal Jan 07 '21 at 19:13
  • @GertvandenBerg if ls -l /usr/bin/cc doesn't yield result after installing an older version of GCC and sym linking it, what does it mean and how could it be fixed? – Mona Jalal Jan 07 '21 at 19:16
  • @MonaJalal The idea of update-alternatives is that multiple versions can be installed and switched between easily... If the symlinks were messed with, it won't update what things point to... (Normally `/usr/bin/cc` point to that) (If the tools gets installed from outside the package manager, they often don't know the distributions method of doing stuff and override things) – Gert van den Berg Jan 08 '21 at 12:25