Fedora Linux Support Community & Resources Center
  #1  
Old 4th November 2004, 10:34 AM
TheProgrammer Offline
Registered User
 
Join Date: Nov 2004
Location: WA, USA
Posts: 64
How do I use gcc in shell environment?

How do I use gcc in shell environment? I have trouble with starting GUI desktop, so I'm stay at shell environment for now. I want to start using gcc now. However, it doesn't seem to work either.
Reply With Quote
  #2  
Old 4th November 2004, 11:39 AM
TheProgrammer Offline
Registered User
 
Join Date: Nov 2004
Location: WA, USA
Posts: 64
Ok, I did rpm -q gcc and it returns a messenge "gcc package is not install"

Could anyone tell me how do I install the package? The weird thing is, I did select the
development tool to be installed in the installation process. Anyway, what now?

Thanks
Reply With Quote
  #3  
Old 4th November 2004, 11:50 AM
VillageIdiot02 Offline
Registered User
 
Join Date: Jul 2004
Location: Huntsville, AL
Age: 30
Posts: 27
Type
Code:
yum install gcc
and it will d/l and resolve dependencies for you.
__________________
"Are you here to learn the PC or an OS?"
Reply With Quote
  #4  
Old 5th November 2004, 01:46 AM
TheProgrammer Offline
Registered User
 
Join Date: Nov 2004
Location: WA, USA
Posts: 64
wow, thanks. It works. So is yum similar to Windows Update from Mircosoft? Awesome!!

Now, I created a folder, and a C file named hello.c

then I type: gcc -c hello.c

now the folder has one more file named hello.o

Is it an object file? I tried to execute it, but it doesn't work

so I tried: gcc hello.c and it created a.out. I guess that is the executable name,
so I tried to execute it. But I still can execute it!! How do I compile a source
file and execute it?

What is the difference of gcc -c and gcc ?


Thanks
Reply With Quote
  #5  
Old 5th November 2004, 02:55 AM
salaneking Offline
Registered User
 
Join Date: Oct 2004
Location: Mason OH
Age: 55
Posts: 17
I'm more of a hack than a programmer but usually the command for compiling a program is the command "make" sometimes an adj is used such as make all or make install or try this one make --help. man is your friend man
for man gcc you get
gcc - GNU project C and C++ compiler

SYNOPSIS
gcc [-c│-S│-E] [-std=standard]
[-g] [-pg] [-Olevel]
[-Wwarn...] [-pedantic]
[-Idir...] [-Ldir...]
[-Dmacro[=defn]...] [-Umacro]
[-foption...] [-mmachine-option...]
[-o outfile] infile...

Only the most useful options are listed here; see below for the remain-
der. g++ accepts mostly the same options as gcc.

DESCRIPTION
When you invoke GCC, it normally does preprocessing, compilation,
assembly and linking. The ‘‘overall options’’ allow you to stop this
process at an intermediate stage. For example, the -c option says not
to run the linker. Then the output consists of object files output by
the assembler.
>> most cut out. for man make you get this discription
DESCRIPTION
The purpose of the make utility is to determine automatically which
pieces of a large program need to be recompiled, and issue the commands
to recompile them. The manual describes the GNU implementation of
make, which was written by Richard Stallman and Roland McGrath. Our
examples show C programs, since they are most common, but you can use
make with any programming language whose compiler can be run with a
shell command. In fact, make is not limited to programs. You can use
it to describe any task where some files must be updated automatically

>> most snipped
at the end of the man page you sometimes find related commands
I hope this gets you started also search for gcc HOWTO on the internet there should be some info.
Reply With Quote
  #6  
Old 5th November 2004, 03:22 AM
TheProgrammer Offline
Registered User
 
Join Date: Nov 2004
Location: WA, USA
Posts: 64
Thanks for your reply.

I'm just compiling a file, hello.c, not a whole project which contains several files, so I don't need to use "make". Besides, in order to use make, I need to know how a source file is compiled.

I have compiled it, and I got "a.out", now how do I run it? sh a.out doesn't work.

Thanks
Reply With Quote
  #7  
Old 5th November 2004, 03:55 AM
salaneking Offline
Registered User
 
Join Date: Oct 2004
Location: Mason OH
Age: 55
Posts: 17
hello.c


#include <stdio.h>
main()
{
(void) printf("Hello World\n");
return (0);
}
made file hello.c
gcc hello.c -o hello
ran command
./hello
output is
Hello World
gcc doesn't create a shell script
sh is a bash or other type of shell script command
gcc creates a binary file which you can run directly without passing it thru bash
Reply With Quote
  #8  
Old 5th November 2004, 04:39 AM
Jman Offline
Registered User
 
Join Date: Mar 2004
Location: Minnesota, USA
Age: 28
Posts: 7,909
gcc -c is gcc with the -c option, to compile the source file.
Reply With Quote
Reply

Tags
environment, gcc, shell

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
What Dev Environment do you use, and how? dragonbite Wibble 20 6th October 2009 02:52 PM
Shell: How to know all the environment variables guarriman Using Fedora 5 18th February 2008 07:56 PM
Mac OS environment carlman001 Using Fedora 6 22nd February 2007 06:41 AM
FC3: gdm under KDE environment? johndoe2k EOL (End Of Life) Versions 2 19th June 2005 03:15 AM


Current GMT-time: 02:13 (Friday, 21-11-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat
Amherst - Bantval - Betong Travel Photos on Instagram