Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to compile simple c program in Linux Mint 15

Tags:

I am a Linux Mint 15 User.
i wanted to write simple program in C.
Below is my code.(hw.c)

#include<stdio.h> #include<conio.h> int main() {     printf("Hello World"); } 

But, when i try to compile it with gcc

gcc -o hw hw.c 

it gives me an error

hw.c:1:18: fatal error: stdio.h: No such file or directory compilation terminated. 

I googled and found some solutions which say to install build-essential
and tried to install it

sudo apt-get install build-essintial 

but it gives an error again. The error is

    Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation:  The following packages have unmet dependencies:  build-essential : Depends: libc6-dev but it is not going to be installed or                             libc-dev                    Depends: g++ (>= 4:4.4.3) but it is not going to be installed                    Depends: dpkg-dev (>= 1.13.5) but it is not going to be installed E: Unable to correct problems, you have held broken packages. 

So what is wrong? What is the problem?
How to solve it?

PS. The result of locate stdio.h is

/usr/lib/perl/5.14.2/CORE/nostdio.h /usr/lib/syslinux/com32/include/stdio.h 
like image 946
namco Avatar asked Oct 21 '13 16:10

namco


People also ask

Does Linux Mint have C compiler?

The GNU compiler collection, which is the abbreviation for GCC, contains multiple compilers for various languages like C, C++, Go, etc. Using GCC, you can easily compile your programs on Linux Mint.

Where is Stdio H located in Linux?

p.s. the standard location on *nix systems would be /usr/include/stdio. h, i.e., #include looks in /usr/include and other -I directories passed as arguments to the compiler. Show activity on this post. stdio.


2 Answers

I was having the same problem, and simply installed the g++ package and that fixed the missing include file.

sudo apt-get install g++

like image 196
david Avatar answered Sep 29 '22 12:09

david


I had this situation before:

    rleclerc@fvrwbp01:~# gcc -o tokens tokens.c     tokens.c:1:19: fatal error: stdio.h: No such file or directory     compilation terminated. 

You wrote:

    sudo apt-get install build-essintial 

There's a typo. Try this instead (I guess you already did something similar):

    sudo apt-get install --no-install-recommends gcc 

and:

    sudo apt-get install --no-install-recommends build-essential 

Sometimes, proof-reading makes some difference:

    The following NEW packages will be installed:       build-essential dpkg-dev g++ g++-4.7 libc-dev-bin libc6-dev libdpkg-perl libstdc++6-4.7-dev libtimedate-perl linux-libc-dev make     (...) 

This fixed the error.

like image 24
догонят Avatar answered Sep 29 '22 10:09

догонят