newbie question - gcc under linux, getting started 
Author Message
 newbie question - gcc under linux, getting started

Probably the answer to this is very simple, but sometimes its the really
obvious things that the manuals seem not to mention!

i'm just setting out to work through the k&r book 'ansi c', using linux
(red hat) as the platform.

i managed to compile hello world fine, using emacs to write the program
(it seems to go into a nice 'c' friendly mode, though i've not worked
out what that does yet) and then doing

gcc hello.c

to compile. just like the book says, the result is 'a.out'. but how do i
run this? typing 'a.out' (in the terminal), bash won't do it. is there a
final stage that i've missed?

also can anyone tell me is there any kind of IDE that i can use with
gcc? working from terminal is not so bad, but i kind of find ide's
easier.

thanks for all help

Daniel



Thu, 06 Mar 2003 03:00:00 GMT  
 newbie question - gcc under linux, getting started

Quote:
>i managed to compile hello world fine, using emacs to write the program
>(it seems to go into a nice 'c' friendly mode, though i've not worked
>out what that does yet) and then doing

>gcc hello.c

>to compile. just like the book says, the result is 'a.out'. but how do i
>run this? typing 'a.out' (in the terminal), bash won't do it. is there a
>final stage that i've missed?

>also can anyone tell me is there any kind of IDE that i can use with
>gcc? working from terminal is not so bad, but i kind of find ide's
>easier.

If you want to run a program from your current directory, precede it with ./

for example, to run a.out you would type :   ./a.out

I use nedit or kwrite for editing code and run gcc from the command line
so I can't help with the IDE part of your question......

Darry



Thu, 06 Mar 2003 03:00:00 GMT  
 newbie question - gcc under linux, getting started

Quote:

> i'm just setting out to work through the k&r book 'ansi c', using linux
> (red hat) as the platform.

Congratulations, it's a good book.

Quote:
> i managed to compile hello world fine, using emacs to write the
> program (it seems to go into a nice 'c' friendly mode, though
> i've not worked out what that does yet) and then doing

Note that you can tell Emacs do indent C code just the same way
as in your book (Type `C-h i d m cc <RET>' to find out how).  If
you have questions about this, ask in gnu.emacs.help

Quote:
> gcc hello.c

> to compile. just like the book says, the result is 'a.out'. but how do i
> run this? typing 'a.out' (in the terminal), bash won't do it. is there a
> final stage that i've missed?

You probably don't have the current directory, called `.', in
your PATH environment variable.  That's ok, you _shouldn't_ have
. in your PATH.  But then you have to run the program as

$ ./a.out

For more about this, ask in comp.unix.shell or something.

Quote:
> also can anyone tell me is there any kind of IDE that i can use
> with gcc? working from terminal is not so bad, but i kind of
> find ide's easier.

Emacs is much more powerful than any IDE around, just learn to
use it.  If you have problems with C code, ask here.
--
Nils Goesche
Ask not for whom the <CONTROL-G> tolls.


Fri, 07 Mar 2003 07:09:31 GMT  
 newbie question - gcc under linux, getting started
[snip]
Quote:
>gcc hello.c

>to compile. just like the book says, the result is 'a.out'. but how do i
>run this? typing 'a.out' (in the terminal), bash won't do it. is there a
>final stage that i've missed?

[snip]
Your question is system specific and therefore offtopic in clc, which is
about ANSI C only and not system specifics.

<OT>
Under linux the curent dir is not part of the search path (like under DOS)
so you'll have to give the full path. Normally typing ./a.out will do the
trick for you.
</OT>

If you have any more questions about this, please ask in a linux or unix
group.

Stef



Fri, 07 Mar 2003 07:07:48 GMT  
 newbie question - gcc under linux, getting started
Thanks to all for help.

Sorry if the q was not to the right group.

regards

Daniel

Quote:


> > i'm just setting out to work through the k&r book 'ansi c', using linux
> > (red hat) as the platform.

> Congratulations, it's a good book.

> > i managed to compile hello world fine, using emacs to write the
> > program (it seems to go into a nice 'c' friendly mode, though
> > i've not worked out what that does yet) and then doing

> Note that you can tell Emacs do indent C code just the same way
> as in your book (Type `C-h i d m cc <RET>' to find out how).  If
> you have questions about this, ask in gnu.emacs.help

> > gcc hello.c

> > to compile. just like the book says, the result is 'a.out'. but how do i
> > run this? typing 'a.out' (in the terminal), bash won't do it. is there a
> > final stage that i've missed?

> You probably don't have the current directory, called `.', in
> your PATH environment variable.  That's ok, you _shouldn't_ have
> . in your PATH.  But then you have to run the program as

> $ ./a.out

> For more about this, ask in comp.unix.shell or something.

> > also can anyone tell me is there any kind of IDE that i can use
> > with gcc? working from terminal is not so bad, but i kind of
> > find ide's easier.

> Emacs is much more powerful than any IDE around, just learn to
> use it.  If you have problems with C code, ask here.
> --
> Nils Goesche
> Ask not for whom the <CONTROL-G> tolls.



Fri, 07 Mar 2003 14:00:04 GMT  
 newbie question - gcc under linux, getting started

Quote:
> >i managed to compile hello world fine, using emacs to write the program
> >(it seems to go into a nice 'c' friendly mode, though i've not worked
> >out what that does yet) and then doing

> >gcc hello.c

> >to compile. just like the book says, the result is 'a.out'. but how do i
> >run this? typing 'a.out' (in the terminal), bash won't do it. is there a
> >final stage that i've missed?

> >also can anyone tell me is there any kind of IDE that i can use with
> >gcc? working from terminal is not so bad, but i kind of find ide's
> >easier.

Note that this is Off Topic in this list... You can ask here how to write
a hello world program, not how to run it :)

In any case, make sure your permissions for a.out are correct, this is
the most common problem. Find where a.out is located and add
an executing permission to it:

(I'm on AIX, hope its the same on Linux)

chmod 744 a.out

then, run a.out

Should say hello now :)



Fri, 07 Mar 2003 15:37:25 GMT  
 newbie question - gcc under linux, getting started

Quote:
>In any case, make sure your permissions for a.out are correct, this is
>the most common problem.

This is a highly uncommon problem for an a.out file you've generated
yourself by invoking the compiler driver.  It has NEVER happened to me.

Quote:
>Find where a.out is located and add
>an executing permission to it:

>(I'm on AIX, hope its the same on Linux)

>chmod 744 a.out

What's wrong with "chmod +x a.out", which is a lot less cryptical for the
Unix newbie (which the OP obviously is)?

Quote:
>then, run a.out

>Should say hello now :)

Nope, if it didn't before, it won't now either, because you've fixed a
non-existing problem.

The real "problem" is that the OP's $PATH was correctly set NOT to include
the current directory.  And the real solution is for the OP to learn how
to use Unix *before* learning how to program on Unix.

Dan
--
Dan Pop
CERN, IT Division

Mail:  CERN - IT, Bat. 31 1-014, CH-1211 Geneve 23, Switzerland



Fri, 07 Mar 2003 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Linux/GCC Newbie question

2. newbie question re: getting started

3. gcc memroy alignment question on linux

4. newbie getting started with edit controls that work in XP

5. newbie: getting started with controls

6. Newbie Needs Getting Started Lesson

7. Newbie Question:Ctrl-Z causes gcc to fail

8. @> 5 getting started questions

9. Getting started with threads question

10. Easy Question: Getting Started

11. quick question on getting started

12. Where to start question from .Net newbie

 

 
Powered by phpBB® Forum Software