LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-19-2009, 04:58 PM   #1
knightstreet
LQ Newbie
 
Registered: Oct 2009
Posts: 3

Rep: Reputation: 0
Trouble compiling simple hello world program


Hi,

I'm a newbie to linux and have installed debian on my machine.

I installed gcc and am trying to compile a really really basic 'hello world' app but am having problems. I'm not sure this is the right thread/forum to post this on so go easy if I'm in the wrong park!

The code is thus:


Code:
#include <stdio.h>

int main(void)
{
printf("Hello world");
}

Complex eh?

I use the following to compile:

gcc -o program main.c

I get the followign error messages related to stdio.h:

/usr/include/libio.h:332: error: expected specifier-qualifier-list before size_t

I have a lot more similar messages. Can anyone help me out?

Thanks,

Chris.
 
Old 10-19-2009, 05:27 PM   #2
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Jessie (Fluxbox WM)
Posts: 1,387
Blog Entries: 52

Rep: Reputation: 355Reputation: 355Reputation: 355Reputation: 355
What are the first few errors you are getting? It looks like it is not finding some of the header files included by stdio.h.

How did you install gcc?
 
Old 10-19-2009, 06:25 PM   #3
knightstreet
LQ Newbie
 
Registered: Oct 2009
Posts: 3

Original Poster
Rep: Reputation: 0
Hi neonsignal,

I installed it using : apt-get install gcc

The install seems to have worked, I do gcc --version and it goves me Debian 4.3.2-1.1

The remainder of the errors are similar pointing to libio.h and 'expected declaration specifiers' mainly.

I'll try to get the log but I'm running a VM and am having difficulty with the shared folders.
 
Old 10-19-2009, 07:06 PM   #4
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Jessie (Fluxbox WM)
Posts: 1,387
Blog Entries: 52

Rep: Reputation: 355Reputation: 355Reputation: 355Reputation: 355
The errors are because size_t and probably other standard types have not been defined.

I expect that one of the first error messages would be a failed include. This might be a path problem, or a package that didn't install properly - in a standard installation, you normally wouldn't have to do anything to get this working.
 
Old 10-19-2009, 07:20 PM   #5
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Jessie (Fluxbox WM)
Posts: 1,387
Blog Entries: 52

Rep: Reputation: 355Reputation: 355Reputation: 355Reputation: 355
Perhaps try installing the following packages:
Code:
apt-get install build-essential libc6-dev
 
Old 10-19-2009, 07:42 PM   #6
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,330

Rep: Reputation: 227Reputation: 227Reputation: 227
post all the errors.
 
Old 10-19-2009, 08:03 PM   #7
knightstreet
LQ Newbie
 
Registered: Oct 2009
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks neonsignal, that fixed my problem.

I figured a normal install would put all the path declarations in for me and I wouldn't have to do much.

Thanks again for the help, I really appreciate it.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
cannot compile simple hello world C++ program in Emacs Rafael.Pascual Linux - Newbie 1 05-30-2009 02:02 PM
Have a trouble with compiling simple dirver. sulacco Programming 26 01-16-2009 10:48 AM
RTAI - Can't compile simple.c with gcc (hello world program) mario-vallejo Linux - General 1 04-23-2008 09:13 AM
compiling a simple program with qt fakie_flip Linux - Software 1 01-18-2006 02:33 AM
Trouble Compiling a simple Hellow World on Solaris 9 with GCC 3.4.2 jitendra64 Solaris / OpenSolaris 4 10-11-2004 03:57 PM


All times are GMT -5. The time now is 09:17 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration