 |
 |
 |
 |
| Using Fedora General support for current versions. Ask questions about Fedora and it's software that do not belong in any other forum. |

4th November 2004, 09:34 AM
|
|
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.
|

4th November 2004, 10:39 AM
|
|
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
|

4th November 2004, 10:50 AM
|
|
Registered User
|
|
Join Date: Jul 2004
Location: Huntsville, AL
Age: 28
Posts: 27

|
|
Type and it will d/l and resolve dependencies for you.
__________________
"Are you here to learn the PC or an OS?"
|

5th November 2004, 12:46 AM
|
|
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
|

5th November 2004, 01:55 AM
|
|
Registered User
|
|
Join Date: Oct 2004
Location: Mason OH
Age: 53
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.
|

5th November 2004, 02:22 AM
|
|
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
|

5th November 2004, 02:55 AM
|
|
Registered User
|
|
Join Date: Oct 2004
Location: Mason OH
Age: 53
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
|

5th November 2004, 03:39 AM
|
|
Registered User
|
|
Join Date: Mar 2004
Location: Minnesota, USA
Age: 27
Posts: 7,909

|
|
|
gcc -c is gcc with the -c option, to compile the source file.
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Hybrid Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
Current GMT-time: 04:53 (Wednesday, 22-05-2013)
|
|
 |
 |
 |
 |
|
|