LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-20-2007, 10:08 AM   #1
jat12
LQ Newbie
 
Registered: Nov 2007
Posts: 5

Rep: Reputation: 0
Help. New to Linux. Simple Code. Many Errors.


help. i tried making a simple code on linux.

#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
 
Old 11-20-2007, 12:14 PM   #2
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,337

Rep: Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548
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?


-----------------
Steve Stites
 
Old 11-20-2007, 01:49 PM   #3
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 475Reputation: 475Reputation: 475Reputation: 475Reputation: 475
Moved: This thread is more suitable in Programming and has been moved accordingly to help your thread/question get the exposure it deserves.
 
Old 11-20-2007, 02:20 PM   #4
kav
Member
 
Registered: May 2006
Location: USA
Distribution: FreeBSD Ubuntu Debian
Posts: 137

Rep: Reputation: 15
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.
 
Old 11-20-2007, 11:28 PM   #5
ravi_chobey
Member
 
Registered: Sep 2007
Location: Bangalore,India
Distribution: Fedora,Mandriva,Debian
Posts: 180

Rep: Reputation: 30
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.
 
Old 11-22-2007, 05:05 AM   #6
jat12
LQ Newbie
 
Registered: Nov 2007
Posts: 5

Original Poster
Rep: Reputation: 0
i'll first try what you all suggested. thanks.
 
Old 11-22-2007, 08:56 AM   #7
PAix
Member
 
Registered: Jul 2007
Location: United Kingdom, W Mids
Distribution: SUSE 11.0 as of Nov 2008
Posts: 195

Rep: Reputation: 40
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.

PAix

Last edited by PAix; 11-22-2007 at 08:58 AM.
 
Old 11-24-2007, 02:02 AM   #8
LinuxManMikeC
Member
 
Registered: Nov 2007
Location: Provo, Utah
Distribution: Debian and Ubuntu
Posts: 74

Rep: Reputation: 15
Exclamation

Quote:
Originally Posted by jailbait View Post
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with a simple If/Else code in C Exsiss Programming 4 10-02-2007 02:37 AM
Simple Question - Linux x Windows code pingu99 General 4 01-06-2006 04:53 PM
errors with simple C++ Code... openGL problem? poeta_boy Programming 4 11-08-2004 12:34 PM
G++ - why am i getting errors compiling this simple code leroy27336 Programming 4 11-18-2003 08:32 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration