gcc trouble...am i missing something?

gcc trouble...am i missing something?

Post by Arthur Gais » Mon, 18 Feb 2002 11:49:58



installed red hat 7.2
disclaimer: I haven't worked in any unix like environment or in c in
years.
now I was trying to compile a simple c file and it compiled ok (it
gave me errors when there were errors).
I have a simple hello world file named test.c :
#include <stdio.h>
int main(){
  printf("hello world\n");
  return 0;
Quote:}

I did this on the command line:
gcc test.c -o test
(and I tried other combinations...
I end up with a file named test
but when I type:
test <enter>
on the command line I get nothing, even though it should be printing
out "hello world"????
what did i do wrong???

thx in advance

 
 
 

gcc trouble...am i missing something?

Post by Tony Curti » Mon, 18 Feb 2002 11:53:25


>> On 16 Feb 2002 18:49:58 -0800,

> installed red hat 7.2 disclaimer: I haven't worked in
> any unix like environment or in c in years.  now I was
> trying to compile a simple c file and it compiled ok (it
> gave me errors when there were errors).  I have a simple
> hello world file named test.c : #include <stdio.h> int
> main(){ printf("hello world\n"); return 0;
> }
> I did this on the command line: gcc test.c -o test (and
> I tried other combinations...  I end up with a file
> named test but when I type: test <enter> on the command
> line I get nothing, even though it should be printing
> out "hello world"????  what did i do wrong???

Type in "which test".  Then "man test".  Enlightenment
follows.

Running your program as "./test" will do what you want it
to.

--
Oh!  I've said too much.  Smithers, use the amnesia ray.

 
 
 

gcc trouble...am i missing something?

Post by N/A » Mon, 18 Feb 2002 11:57:21


On Saturday 16 February 2002 21:49, `Arthur Gaisin' of


> installed red hat 7.2
> disclaimer: I haven't worked in any unix like environment or in
> c in years.
> now I was trying to compile a simple c file and it compiled ok
> (it gave me errors when there were errors).
> I have a simple hello world file named test.c :
> #include <stdio.h>
> int main(){
>   printf("hello world\n");
>   return 0;
> }
> I did this on the command line:
> gcc test.c -o test
> (and I tried other combinations...
> I end up with a file named test
> but when I type:
> test <enter>
> on the command line I get nothing, even though it should be
> printing out "hello world"????
> what did i do wrong???

> thx in advance

You've just discovered the beauty of a un*x OS, i.e. Linux.  Do
a "./test" instead of "test" to run your newly compiled "test"
program.
 
 
 

gcc trouble...am i missing something?

Post by Robert Helle » Mon, 18 Feb 2002 14:27:58



  In a message on 16 Feb 2002 18:49:58 -0800, wrote :

AG> installed red hat 7.2
AG> disclaimer: I haven't worked in any unix like environment or in c in
AG> years.
AG> now I was trying to compile a simple c file and it compiled ok (it
AG> gave me errors when there were errors).
AG> I have a simple hello world file named test.c :
AG> #include <stdio.h>
AG> int main(){
AG>   printf("hello world\n");
AG>   return 0;
AG> }
AG> I did this on the command line:
AG> gcc test.c -o test
AG> (and I tried other combinations...
AG> I end up with a file named test
AG> but when I type:
AG> test <enter>
AG> on the command line I get nothing, even though it should be printing
AG> out "hello world"????
AG> what did i do wrong???
AG>
AG> thx in advance
AG>                              

1) There is a program built in called test.

2) Your path does not include the current directory (this is a security
feature).

Result: when you type 'test' you are running the system test program:

from 'man test':

TEST(1)                        FSF                        TEST(1)

NAME
       test - check file types and compare values

SYNOPSIS
       test EXPRESSION
       test EXPRESSION ]
       test OPTION

DESCRIPTION
       Exit with the status determined by EXPRESSION.

sauron.deepsoft.com% which test
/usr/bin/test

/usr/bin/test with no arguments 'quietly' returns -- it sets $status to
something, but does not send anything to stdout.

You need to type './test', or better:

mv test.c helloworld.c
mv test   helloworld
./helloworld

--
                                     \/


http://www.deepsoft.com              /\FidoNet:    1:321/153

 
 
 

gcc trouble...am i missing something?

Post by Peter T. Breue » Mon, 18 Feb 2002 15:39:50



> disclaimer: I haven't worked in any unix like environment or in c in
> years.

See the unix FAQ. You do not call test programs "test". There is
already a program called "test" on your disk.

Quote:> I end up with a file named test
> but when I type:
> test <enter>
> on the command line I get nothing, even though it should be printing
> out "hello world"????
> what did i do wrong???

Not reading the unix FAQ. Think about the value of your PATH.

Peter

 
 
 

gcc trouble...am i missing something?

Post by John Thompso » Mon, 18 Feb 2002 22:04:17



> installed red hat 7.2
> disclaimer: I haven't worked in any unix like environment or in c in
> years.
> now I was trying to compile a simple c file and it compiled ok (it
> gave me errors when there were errors).
> I have a simple hello world file named test.c :
> #include <stdio.h>
> int main(){
>   printf("hello world\n");
>   return 0;
> }
> I did this on the command line:
> gcc test.c -o test
> (and I tried other combinations...
> I end up with a file named test
> but when I type:
> test <enter>
> on the command line I get nothing, even though it should be printing
> out "hello world"????
> what did i do wrong???

Remember, there is a rather important system utility named "test."  
Chances are, /usr/bin/test is being run instead of your program.

Also remember that by default, the current directory is not included in
your $PATH.  Try "./test" to explicitly run the program in your current
diretory.

--


 
 
 

1. I am missing something simple

Hey all!

The newbie got the complilers to work, even found the <stdio.h> header
in one of the redhat 5.1 rpm's.  I am able to compile a simple "hello
world" c source file but I cannot get it to execute (a.out).  I am
running the bash shell.  I change the permissions tochmos 777 a.out (rwx
to all groups), but when I try to run it, I get "bash: a.out unknown
command"

Can you help?  I think is is something so simple that it is under my
nose!

JL
remove the underlines and "nospam" to email

2. powerfail setup

3. Am I missing something with the 5.0 ISO images?

4. WIN 98 as a Gateway?

5. Bug in cardbus initialization, or am I missing something?

6. RAID5 and Mirroring the OS

7. Am I missing something or does Netscape's NEWS reader suck?

8. Termcap problem? scroll area confused.

9. date/time, Am I missing something?

10. Xconfigurator-am I missing something?

11. Am I Missing Something???

12. named configuration - am I missing something obvious ?

13. Am I missing something?