-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:~$

2 Answers2

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.

  • root@vishal-HP-Notebook:/home/vishal# gcc v.c root@vishal-HP-Notebook:/home/vishal# a.out a.out: command not found – VISHAL SINGH Sep 24 '18 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. – Chai T. Rex Sep 24 '18 at 11:12
  • 2
    @VISHALSINGH, try ./a.out. I think that the current directory is not in the PATH by default. – Niclas Börlin Sep 24 '18 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:~$

    – VISHAL SINGH Sep 24 '18 at 11:15
  • vishal@vishal-HP-Notebook:~$ gcc v.c vishal@vishal-HP-Notebook:~$ ./a.out Muditvishal@vishal-HP-Notebook:~$ – VISHAL SINGH Sep 24 '18 at 11:17
  • I Want to set it default for CODEBLOCKS IDE – VISHAL SINGH Sep 24 '18 at 11:17
  • OUTPUT IN CODEBLOCKS-------------- Build: Debug in m (compiler: GNU GCC Compiler)---------------

    g++ -Wall -fexceptions -g -c /home/vishal/Documents/m/main.cpp -o obj/Debug/main.o /bin/sh: 1: g++: not found Process terminated with status 127 (0 minute(s), 0 second(s)) 0 error(s), 0 warning(s) (0 minute(s), 0 second(s))

    – VISHAL SINGH Sep 24 '18 at 11:20
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

D-unit
  • 319
  • 1
  • 15
  • I guess you mean gcc --version (two dashes). – Niclas Börlin Sep 24 '18 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#

    – VISHAL SINGH Sep 24 '18 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 '18 at 11:15