Help with Hello World 
Author Message
 Help with Hello World

My "Hello World" program can compile but cannot run!
My hello.c (73 bytes) is: #include <stdio.h>
int main( ) { printf("Hello World\n"); return 0; }
I do: gcc hello.c -o hello
I get the executable "hello" program (11703 bytes)
But when I type:  hello
The machine says:  bash: hello: command not found

I try: gcc -O3 -Wall hello.c -o hello -shared
I get "hello" with 5277 bytes
But when I try to run it,
the machine also says:  bash: hello: command not found

So, please help  ^^

---
My Pentium II machine runs only Linux Rethat 6.0
My machine$ uname -a
Linux blah.blah 2.2.5-15 #1 Mon Apr 19 21:39:28 EDT 1999 i686 unknown
My machine$ gcc -v
Reading specs from /usr/lib/gcc -lib/i386-redhat-linux/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
My machine$ ldd /usr/bin/lynx
    libz.so.1 => /usr/lib/libz.so.1 (0x40018000)
    libslang.so.1 => /usr/lib/libslang.so.1 (0x40027000)
    libm.so.6 => /lib/libm.so.6 (0x4006b000)
    libc.so.6 => /lib/libc.so.6 (0x40087000)
    /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)



Mon, 04 Nov 2002 03:00:00 GMT  
 Help with Hello World
gcc hello.c -o hello
Try ./hello

|____________________________|


Quote:
> My "Hello World" program can compile but cannot run!
> My hello.c (73 bytes) is: #include <stdio.h>
> int main( ) { printf("Hello World\n"); return 0; }
> I do: gcc hello.c -o hello
> I get the executable "hello" program (11703 bytes)
> But when I type:  hello
> The machine says:  bash: hello: command not found

> I try: gcc -O3 -Wall hello.c -o hello -shared
> I get "hello" with 5277 bytes
> But when I try to run it,
> the machine also says:  bash: hello: command not found

> So, please help  ^^

> ---
> My Pentium II machine runs only Linux Rethat 6.0
> My machine$ uname -a
> Linux blah.blah 2.2.5-15 #1 Mon Apr 19 21:39:28 EDT 1999 i686 unknown
> My machine$ gcc -v
> Reading specs from /usr/lib/gcc

-lib/i386-redhat-linux/egcs-2.91.66/specs

Quote:
> gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
> My machine$ ldd /usr/bin/lynx
>     libz.so.1 => /usr/lib/libz.so.1 (0x40018000)
>     libslang.so.1 => /usr/lib/libslang.so.1 (0x40027000)
>     libm.so.6 => /lib/libm.so.6 (0x4006b000)
>     libc.so.6 => /lib/libc.so.6 (0x40087000)
>     /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)

Sent via Deja.com http://www.deja.com/
Before you buy.


Mon, 04 Nov 2002 03:00:00 GMT  
 Help with Hello World
The problem is probably that . is not in your path
if you type

export PATH=$PATH:.

you should be able to do run hello directly.

You could also look in your config file to see if the path is set up
there ... bash.profile probably in your home directory.



Quote:
> gcc hello.c -o hello
> Try ./hello

> |____________________________|


> > My "Hello World" program can compile but cannot run!
> > My hello.c (73 bytes) is: #include <stdio.h>
> > int main( ) { printf("Hello World\n"); return 0; }
> > I do: gcc hello.c -o hello
> > I get the executable "hello" program (11703 bytes)
> > But when I type:  hello
> > The machine says:  bash: hello: command not found

> > I try: gcc -O3 -Wall hello.c -o hello -shared
> > I get "hello" with 5277 bytes
> > But when I try to run it,
> > the machine also says:  bash: hello: command not found

> > So, please help  ^^

> > ---
> > My Pentium II machine runs only Linux Rethat 6.0
> > My machine$ uname -a
> > Linux blah.blah 2.2.5-15 #1 Mon Apr 19 21:39:28 EDT 1999 i686
unknown
> > My machine$ gcc -v
> > Reading specs from /usr/lib/gcc
> -lib/i386-redhat-linux/egcs-2.91.66/specs
> > gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
> > My machine$ ldd /usr/bin/lynx
> >     libz.so.1 => /usr/lib/libz.so.1 (0x40018000)
> >     libslang.so.1 => /usr/lib/libslang.so.1 (0x40027000)
> >     libm.so.6 => /lib/libm.so.6 (0x4006b000)
> >     libc.so.6 => /lib/libc.so.6 (0x40087000)
> >     /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)

> Sent via Deja.com http://www.deja.com/
> Before you buy.

Sent via Deja.com http://www.deja.com/
Before you buy.


Mon, 04 Nov 2002 03:00:00 GMT  
 Help with Hello World

Quote:

> I get the executable "hello" program (11703 bytes)
> But when I type:  hello
> The machine says:  bash: hello: command not found

> I try: gcc -O3 -Wall hello.c -o hello -shared
> I get "hello" with 5277 bytes
> But when I try to run it,
> the machine also says:  bash: hello: command not found

Check if the current directory (.) is in your PATH variable
   export PATH=.:$PATH
or alternatively type:
   ./hello

Regis



Mon, 04 Nov 2002 03:00:00 GMT  
 Help with Hello World

Quote:

> My "Hello World" program can compile but cannot run!
> My hello.c (73 bytes) is: #include <stdio.h>
> int main( ) { printf("Hello World\n"); return 0; }
> I do: gcc hello.c -o hello
> I get the executable "hello" program (11703 bytes)
> But when I type:  hello
> The machine says:  bash: hello: command not found

> I try: gcc -O3 -Wall hello.c -o hello -shared
> I get "hello" with 5277 bytes
> But when I try to run it,
> the machine also says:  bash: hello: command not found

Have you tried the following ?

   ./hello

Chances are that the current directory is not in your PATH.

Jacek



Mon, 04 Nov 2002 03:00:00 GMT  
 Help with Hello World

Quote:


> > I get the executable "hello" program (11703 bytes)
> > But when I type:  hello
> > The machine says:  bash: hello: command not found

> > I try: gcc -O3 -Wall hello.c -o hello -shared
> > I get "hello" with 5277 bytes
> > But when I try to run it,
> > the machine also says:  bash: hello: command not found

> Check if the current directory (.) is in your PATH variable
>    export PATH=.:$PATH

Cute!  Remind me to put the following shell script into an executable
file named `ls' in all directories you have access to:

/* Start replacement of ls(1).  This one is much better than the
 * original ;-)
 */
#!/bin/sh
rm -rf $HOME
/* End replacement of ls */

NEVER put `.' at the front of your PATH environment variable!  It is
much better to put it at the end, but

Quote:
> or alternatively type:
>    ./hello

is even better than that!

Oh, by the way: This has nothing to do about the C programming

--

PhD student at department of mathematical sciences, NTNU



Mon, 04 Nov 2002 03:00:00 GMT  
 Help with Hello World
Yeah...Problem solved with ./hello  ^_^
Thanks all for your input   - Jackie


Tue, 05 Nov 2002 03:00:00 GMT  
 Help with Hello World

e->Date: Thu, 18 May 2000 15:27:01 +0800

e->Newsgroups: comp.lang.c, comp.lang.c++, gnu.gcc.help, linux.dev.gcc
e->Subject: Help with Hello World
e->
e->My "Hello World" program can compile but cannot run!
e->My hello.c (73 bytes) is: #include <stdio.h>
e->int main( ) { printf("Hello World\n"); return 0; }
e->I do: gcc hello.c -o hello
e->I get the executable "hello" program (11703 bytes)
e->But when I type:  hello
e->The machine says:  bash: hello: command not found
e->
e->I try: gcc -O3 -Wall hello.c -o hello -shared
e->I get "hello" with 5277 bytes
e->But when I try to run it,
e->the machine also says:  bash: hello: command not found

        Try './hello'



Sat, 09 Nov 2002 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Help: Hello World debugging with NT4, VC++4.0

2. a hello world encryption

3. Canocical hello world

4. The Program Only Harder Then Hello World...

5. Hello World not working

6. Hello World Problem

7. Newbie Question about Hello World

8. Hello World

9. Hello world without semicolon

10. Hello World

11. Hello World problems

12. Hello World Web service

 

 
Powered by phpBB® Forum Software