0

I was making a c program that includes conio.h library but because I'm on a Debain Based OS, conio.h library is not there pre-installed so I have to search to internet and download it.

After downloading it, I wanted to know the path of GCC to copy the file there because I thought that there was a folder named gcc where all headers file are stored. I searched in the internet to find its path and I saw a blog and they said to run " which gcc " to find it and after I ran it, I got " /usr/bash/gcc ".

Now I made " cp conio.h /usr/bash/gcc " but I always get this error if I want to compile any C file or even to get its version:

" /usr/bin/gcc: line 1: syntax error near unexpected token (' /usr/bin/gcc: line 1:// Copyright (C) 2005 by Piotr He�ka (piotr.helka@nd.e-wro.pl)' "

Every Help Would Be Very Appreciated!

EDIT: I have solved this issue by copying another functioning gcc to the actual one. Even reinstalling won't work. Another way you can solve this, is by downloading a binary of gcc and then copy that binary to the place your old broken gcc is.

thecow milk
  • 109
  • 11
  • 1
    Seems you broke your `gcc` program since you replaced the `/usr/bash/gcc` file with `conio.h` file (you renamed that last file too) You should reinstall `gcc`. Since [`conio.h`](https://en.wikipedia.org/wiki/Conio.h) comes from the MS-DOS world, your program will have difficulties to be compiled on your system. Consider to port it using other tools (like ncurses) – Mathieu Oct 16 '19 at 10:50
  • Maybe `/usr/bash/gcc` was a symbolic link to the real `gcc` program file. In that case, you can try to find it and to restore the link. See [`ln`](https://linux.die.net/man/1/ln) tool. – Mathieu Oct 16 '19 at 10:55
  • You could have just put the conio.h file in the same directory as your .c files. Now you have to reinstall your gcc. By the way, the conio.h you downloaded only works for C++, not for C. – Ian Abbott Oct 16 '19 at 10:56

1 Answers1

0

Oh no! You removed the gcc binary (or symlink...) from your PC and replaced it with the header file.

I would recommend to reinstall gcc first:

sudo apt-get install gcc --reinstall

Now just run gcc to see what it does:

gcc

It should say something like "no input files".

Now about your conio problem, I suggest you read this stackoverflow question: Why can't I find <conio.h> on Linux?

Veda
  • 2,025
  • 1
  • 18
  • 34
  • Hello, thanks for taking your time and answering my post. Well I tried it. Trying to fix it I did: apt-get remove --purge gcc and than apt-get install gcc but the thing. I will try to execute your suggested commands later since I'm not in my laptop right now. – thecow milk Oct 16 '19 at 14:01
  • I also read another stackoverflow post similar to this the link you provided and someone provided a link which I can download the conio.h library on sourceforge. I will update with link later. – thecow milk Oct 16 '19 at 15:08