TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [TCLUG:6686] Newbie using gcc

> I need some help in getting started with gcc. I have a few simple C
> and C++ programs I need compiled on my RedHat 6 system. Where can I
> find some examples of compiling some source code into executable
> programs?

$ gcc input.c -o output
$ ./output
Hello World in C!
$ g++ -o output
$ ./output
Hello World in C++!

The '$' is the prompt, the "Hello World" lines are example outputs..

You (usually) need to add the './' to the command in order for it to run from
the current directory -- that is because the current directory is  not in the
PATH (as opposed to in DOS, where if you type in a command, it looks in the
current directory before looking elsewhere..)
> At this point I have managed to go from 'gcc somefile.c' to getting
> 'a.out' which I cannot do anything with. I know this is really basic
> stuff and I am probably missing some obvious things, but can some one
> let me know where to go from here??

The 'man' command is your friend, learn it, know it, use it..

Also, for any documentation, poke around in the /usr/doc directory or search
around on the Internet..

 _  _  _  _ _  ___    _ _  _  ___ _ _  __   So that's why there are 
/ \/ \(_)| ' // ._\  / - \(_)/ ./| ' /(__   so few Java programs!   
\_||_/|_||_|_\\___/  \_-_/|_|\__\|_|_\ __)  Garbage collection! 
[ Mike Hicks | | ]