1

I am new to ubuntu and running ubuntu 15.10. I was trying to run a C code and got the following error.enter image description here

so I installed it with the given command and now it says:

enter image description here

how to do i run it? New to this so bear with me.

EDIT: the output for echo $PATHis below:enter image description here

When i run the command dpkg --listfiles gcc | grep bin/gcc i get the following output enter image description here

pramesh shakya
  • 143
  • 2
  • 16

1 Answers1

1

It looks like something is wrong with your machine. There are a few things to check if things go wrong.

1. Check the PATH variable

First you need to check that the PATH variable contains the system managed installation directories, such as /usr/bin.

Type echo $PATH on the console and make sure that it contains a sequence of paths delimited by : that contains /usr/bin, as well as /bin

2. Check if the package files are present

Type dpkg --verify gcc ; echo $?. If the package files are present, this command should print out 0.

:~> dpkg --verify gcc ; echo $?
0

Type dpkg --listfiles gcc to get a list of files that were installed when gcc was installed. Check if /usr/bin/gcc is on the list. You could use grep to filter output.

:~> dpkg --listfiles gcc | grep bin/gcc              
/usr/bin/gcc-ranlib
/usr/bin/gcc-nm
/usr/bin/gcc-ar
/usr/bin/gcc

3. Check if there are any conflicts or missing dependencies

Use dpkg --status command.

:~> dpkg --status gcc    
Package: gcc
Status: install ok installed
...
Conflicts: gcc-doc (<< 1:2.95.3)
Description: GNU C compiler
 This is the GNU C compiler, a fairly portable optimizing compiler for C.
 .
 This is a dependency package providing the default GNU C compiler.

Here the command says that the documentation is outdated or missing for the compiler.

4. Check that the file /usr/bin/gcc has correct permissions

It should be executable

:~> ls -l /usr/bin/gcc                 
lrwxrwxrwx 1 root root 7 Feb 25  2015 /usr/bin/gcc -> gcc-4.9

In Ubuntu /usr/bin/gcc is a symbolic link to the correct version of the compiler. Check that the link is valid.

5. Check that the package that contains compiler binary is installed

See what package provides the compiler binary:

:~> dpkg -S /usr/bin/gcc-4.9
gcc-4.9: /usr/bin/gcc-4.9

Repeat steps 2-4 for the package gcc-4.9.

6. Try to run it

Try running the executable with the full path:

:~> /usr/bin/gcc     
gcc: fatal error: no input files
compilation terminated.
:~> /usr/bin/gcc-4.9 
gcc-4.9: fatal error: no input files
compilation terminated.

If any of the above steps fail, this could provide a further hint on the cause of the problem.

Dima Chubarov
  • 16,199
  • 6
  • 40
  • 76
  • while going through the steps(1-3 showed the correct results) , i failed on STep 4, the error it shows is "cannot access /usr/bin/gcc: No such file or directory" – pramesh shakya Nov 18 '16 at 12:37
  • @prameshshakya Do you have `/usr/bin`? If you have `file` utility, `file /usr/bin` should return `directory` – Dima Chubarov Nov 18 '16 at 12:44
  • yes i do have the directory but the gcc folder is missing for some reason, is it okay if i take this to a chat? the site is suggesting so. EDIT:: there are gcc files but no gcc folder, is there supposed to be a gcc folder? – pramesh shakya Nov 18 '16 at 12:46
  • @prameshshakya Yes chat is ok – Dima Chubarov Nov 18 '16 at 13:00