Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Open Source > BOOK Beginning Linux Programming, 3rd Edition
| Search | Today's Posts | Mark Forums Read
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
  #1 (permalink)  
Old July 25th, 2008, 02:23 PM
jch jch is offline
Registered User
 
Join Date: Jul 2008
Location: Queens, NY, USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jch
Default 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?
  #2 (permalink)  
Old July 25th, 2008, 03:09 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

You need to add
    #include <stdlib.h>

You could also turn off the warning, but adding the stdlib is the better answer.
  #3 (permalink)  
Old July 25th, 2008, 04:15 PM
jch jch is offline
Registered User
 
Join Date: Jul 2008
Location: Queens, NY, USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jch
Default

Thanks.

But now I am not getting any out put from the program hello.c.

Is there something else I should do?
  #4 (permalink)  
Old July 25th, 2008, 05:34 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

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.
  #5 (permalink)  
Old July 25th, 2008, 08:17 PM
jch jch is offline
Registered User
 
Join Date: Jul 2008
Location: Queens, NY, USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jch
Default

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?
  #6 (permalink)  
Old August 26th, 2008, 10:33 AM
Friend of Wrox
Points: 1,515, Level: 15
Points: 1,515, Level: 15 Points: 1,515, Level: 15 Points: 1,515, Level: 15
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2003
Location: Oxford, , United Kingdom.
Posts: 488
Thanks: 0
Thanked 3 Times in 3 Posts
Default

try
Code:
./hello
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP "Hello World" Bill_Thompson ASP.NET 2.0 Basics 3 December 14th, 2007 09:38 AM
New programmer - Compiling problems FireShadow C++ Programming 2 November 6th, 2005 10:40 PM
Problems Testing Program in Visual Studio .Net RWR VB.NET 2002/2003 Basics 0 March 5th, 2005 01:07 PM
New to Java, problems compiling Kyle Colyer JSP Basics 3 September 6th, 2003 04:58 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.