 |
BOOK Beginning Linux Programming, 3rd Edition  | This is the forum to discuss the Wrox book Beginning Linux Programming, 2nd Edition by Richard Stones, Neil Matthew, Alan Cox; ISBN: 9780764543739 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK Beginning Linux Programming, 3rd Edition section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

July 25th, 2008, 02:23 PM
|
|
Registered User
|
|
Join Date: Jul 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I am having problems compiling Hello World program
HI, I Am new to the Linux OS and I would like someone to help me solve a problem that I am having.
I have written the first program in the book Begining inux Programming 3rd Edition. The source code is:
#include <stdio.h>
int main()
{
printf("Hello World");
exit(0);
}
It's a very simple program which I saved in my home directory as hello.c.
However, when I compile this program at the bash command line I get the following error message:
charles@linux:~> gcc -o hello hello.c
hello.c: In function âmainâ:
hello.c:6: warning: incompatible implicit declaration of built-in function âexitâ
Is there something wrong with the program or could I be missing some libraries or development tools?
|
|

July 25th, 2008, 03:09 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
|
|
You need to add
#include <stdlib.h>
You could also turn off the warning, but adding the stdlib is the better answer.
|
|

July 25th, 2008, 04:15 PM
|
|
Registered User
|
|
Join Date: Jul 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks.
But now I am not getting any out put from the program hello.c.
Is there something else I should do?
|
|

July 25th, 2008, 05:34 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
|
|
How are you executing the program???
When you execute it, you shouldn't be using "hello.c" at all.
Should just be able to type
hello
at the command prompt.
|
|

July 25th, 2008, 08:17 PM
|
|
Registered User
|
|
Join Date: Jul 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi!
Whenever I type hello at the command line I get the following message:
charles@linux:~> hello
bash: hello: command not found
IS there something else that I can do to correct this?
|
|

August 26th, 2008, 10:33 AM
|
|
Friend of Wrox
|
|
Join Date: Dec 2003
Posts: 488
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
try
The './' tells bash to look for hello in the current working directory
--
Charlie Harvey's website - linux, perl, java, anarchism and punk rock: http://charlieharvey.org.uk
|
|
 |