p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK Beginning Linux Programming, 3rd Edition (http://p2p.wrox.com/forumdisplay.php?f=120)
-   -   I am having problems compiling Hello World program (http://p2p.wrox.com/showthread.php?t=69640)

jch July 25th, 2008 02:23 PM

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");
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?

Old Pedant July 25th, 2008 03:09 PM

You need to add
    #include <stdlib.h>

You could also turn off the warning, but adding the stdlib is the better answer.

jch July 25th, 2008 04:15 PM


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

Is there something else I should do?

Old Pedant July 25th, 2008 05:34 PM

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
at the command prompt.

jch July 25th, 2008 08:17 PM


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?

ciderpunx August 26th, 2008 10:33 AM


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

All times are GMT -4. The time now is 09:58 PM.

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