newbie c question
Arthur Gold
agold@bga.com
Fri Oct 1 00:00:00 GMT 1999
You want to type:
./hello
(assuming that '.', i.e. the current directory, is not in your PATH--as
it most likely
isn't...and shouldn't be)
When looking for executables, *n*x searches only those directories
contained in
your PATH environment variable--do an 'echo $PATH' to see how your PATH
is defined.
For further info, look through your Running Linux book--it discusses the
issue
quite nicely, IIRC.
HTH,
--ag
Robert Luke wrote:
>
> Hello, I'm looking at C for the first time and am trying to compile a simple
> example found in "Running Linux (2ed)" by Matt Welsh and Lar Kaufman. I
> have Caldera OpenLinux 2.2 on my laptop. If someone could tell me what
> bonehead mistake I'm making, I'd be grateful! :-)
>
> 1. I've created a program called "hello.c" which contains the following
> lines:
>
> #include <stdio.h>
> int main() {
> (void)printf("Hello, world!\n");
> return 0;
> }
>
> 2. I compile and run it at the following two prompts:
>
> $ gcc -o hello hello.c
> $ hello
>
> bash: hello: command not found
>
> (I.e., it seems to compile okay, but it doesn't execute.)
>
> 3. My first thought was that the executable file "hello" isn't actually
> executable; but the result of "ls -al" is
>
> -rwxr-xr-x 1 robert users 34935 Aug 22 17:54 hello
>
> Please help! TIA,
> -Robert
More information about the Gcc-help
mailing list