-1

Original error:

root@vishal-HP-Notebook:/home/vishal# sudo apt-get install gcc Reading package lists... Done Building dependency tree
Reading state information... Done gcc is already the newest version (4:7.3.0-3ubuntu2). 0 upgraded, 0 newly installed, 0 to remove and 179 not upgraded. root@vishal-HP-Notebook:/home/vishal# gcc gcc: fatal error: no input files compilation terminated.

root@vishal-HP-Notebook:/home/vishal# sudo apt-get install gcc
Reading package lists... Done
Building dependency tree       
Reading state information... Done
gcc is already the newest version (4:7.3.0-3ubuntu2).
0 upgraded, 0 newly installed, 0 to remove and 179 not upgraded.
root@vishal-HP-Notebook:/home/vishal# gcc
gcc: fatal error: no input files
compilation terminated.

Following Niclas Börlin's answer:

vishal@vishal-HP-Notebook:~$ cat v.c
#include<stdio.h>
void main()
{
printf("Mudit");
}
vishal@vishal-HP-Notebook:~$ gcc v.c
vishal@vishal-HP-Notebook:~$ a.out
a.out: command not found
vishal@vishal-HP-Notebook:~$ gcc --version
gcc (Ubuntu 4.8.5-4ubuntu8) 4.8.5
Copyright (C) 2015 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.

vishal@vishal-HP-Notebook:~$ 

HOW DO I USE IT FOR CODE BLOCKS IDE I've got a method to run on terminal

vishal@vishal-HP-Notebook:~$ cat v.c
#include<stdio.h>
void main()
{
printf("Mudit");
}
vishal@vishal-HP-Notebook:~$ gcc v.c
vishal@vishal-HP-Notebook:~$ ./a.out
Muditvishal@vishal-HP-Notebook:~$
8

2 Answers 2

1

I get the same output when I call gcc without any file names, so it looks like gcc is working.

Try gcc file.c on a file with some c code. If the code is correct, it should produce an executable file called a.out.

7
  • root@vishal-HP-Notebook:/home/vishal# gcc v.c root@vishal-HP-Notebook:/home/vishal# a.out a.out: command not found Sep 24, 2018 at 11:09
  • 1
    @VISHALSINGH Please don't use the root user for this. Even if GCC is broken, it can't be helped by running GCC as root. Also, please add that to your question along with the output of cat v.c. Sep 24, 2018 at 11:12
  • 2
    @VISHALSINGH, try ./a.out. I think that the current directory is not in the PATH by default. Sep 24, 2018 at 11:14
  • vishal@vishal-HP-Notebook:~$ cat v.c #include<stdio.h> void main() { printf("Mudit"); } vishal@vishal-HP-Notebook:~$ gcc v.c vishal@vishal-HP-Notebook:~$ a.out a.out: command not found vishal@vishal-HP-Notebook:~$ gcc --version gcc (Ubuntu 4.8.5-4ubuntu8) 4.8.5 Copyright (C) 2015 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. vishal@vishal-HP-Notebook:~$ Sep 24, 2018 at 11:15
  • vishal@vishal-HP-Notebook:~$ gcc v.c vishal@vishal-HP-Notebook:~$ ./a.out Muditvishal@vishal-HP-Notebook:~$ Sep 24, 2018 at 11:17
0

It is indeed installed

Try the command below and see your current version

> gcc --version

Next go find a tutorial on GCC or read the manual

3
  • I guess you mean gcc --version (two dashes). Sep 24, 2018 at 11:09
  • root@vishal-HP-Notebook:/home/vishal# gcc --version gcc (Ubuntu 4.8.5-4ubuntu8) 4.8.5 Copyright (C) 2015 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. root@vishal-HP-Notebook:/home/vishal# Sep 24, 2018 at 11:11
  • Yes, you can see your version 4.8.5 (pretty old version you are running). This means GCC is installed and working. I think your next step is to read about how you can use GCC now
    – D-unit
    Sep 24, 2018 at 11:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .