Tuesday, July 28, 2009

Where can I find a free C compiler for Ubuntu 7.04?

I've tried gcc, the one that comes with Ubuntu, but it chucks this back at me...





james@james-desktop:~$ gcc guess.c


guess.c:6:19: error: stdio.h: No such file or directory


guess.c:7:56: error: stdlib.h: No such file or directory


guess.c:8:47: error: time.h: No such file or directory


guess.c: In function ‘main’:


guess.c:15: error: ‘NULL’ undeclared (first use in this function)


guess.c:15: error: (Each undeclared identifier is reported only once


guess.c:15: error: for each function it appears in.)


guess.c:20: warning: incompatible implicit declaration of built-in function ‘printf’


guess.c:28: warning: incompatible implicit declaration of built-in function ‘scanf’


guess.c:44:2: warning: no newline at end of file


james@james-desktop:~$ gcc


gcc: no input files


james@james-desktop:~$





which I guess means that it has not compiled! What's wrong?

Where can I find a free C compiler for Ubuntu 7.04?
You are missing the header files that normally come as standard. Ubuntu must have decided that most users don't need to compile stuff.





The first three lines are the problem, the ones after that are caused by those missing header files.





This is easily fixed.





sudo apt-get install build-essential





Enjoy
Reply:guess.c:44:2: warning: no newline at end of file


This line is only a warning (not an error). So you probably have compiled your program.


The warning means that you should go to the last character of your program and hit "Enter". This will add a "carriage return" at the end of the last line. It will probably make the compiler happy.

medium

No comments:

Post a Comment