ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
#include <stdio.h>
int main()
{
printf ("Hello");
}
and I tried compiling it. These errors keep popping up.
a.c:1:19: error: stdio.h: No such file or directory
a.c: In function ‘main’:
a.c:4: warning: incompatible implicit declaration of built-in function ‘printf’
a.c:5:2: warning: no newline at end of file
WHAT'S Wrong??
I'm new to linux environment. please help
stdio.h is provided by the glibc package. There are both source and binary packages which provide glibc. Do you have the glibc source package installed?
What distribution are you running and what package manager are you using?
Most important is what distro you're using. It's probably one that isn't build friendly out of the box. It should be just as easy as you think. Drop the code in a .c, gcc it, then ./a.out. But you're missing your library.
Ubuntu needs a the build essential packages. Debian I think all you need is gcc and I think the dependencies take care of themselves.
check the gcc version using gcc -v command.If its not there,then download the tar package from gnu.org and configure.Else upgrade your O.S, u must have missed the development tools options while installing that distribution.
Hi, your bit of code is a classic almost directly taken from page 6 of The C Programming Language by Kernighan & Ritchie.
Code:
#include <stdio.h>
int main()
{
printf ("Hello");
}
However, your code compiles just fine and works ok, so as Kav and Ravi have said it's down to the development environment not being fully installed. Under SUSE linux select from K Menu > YaST (Control Center) > Software Management and enter gcc in the search box. It will likely show one or two items that are needed.
Like Ubuntu, SUSE doesn't load the development tools by default.
There are both source and binary packages which provide glibc. Do you have the glibc source package installed?
A source package usually refers to a package containing the full source code of some program or library. What this guy needs is just the headers. These should be in a development package (abbreviated as "devel" on some RPM based distros, not sure about others). Actually on my Fedora system I need two glibc packages in addition to the compiled binary, glibc-headers and glibc-devel. You don't need the whole source code of glibc. Sorry if I sound a bit pedantic, but the last thing we need is a newbie getting lost in the glibc source.
Not sure what distro you use jailbait and I'm not familiar with the package naming conventions of them all, but from what I've seen they make a clear distinction between full source and just headers.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.