help!!!

Robert Bernecky bernecky@acm.org
Wed Apr 25 21:58:00 GMT 2001


Let's start at the beginning, because it's not clear what your problem
is. See below...

On Wed, 25 Apr 2001, Patrice Henry wrote:

> This may sound really stupid, but in being a computer technician,
I know what it is to be humbled by your work.
>If you ever want to feel stupid, fix a computer problem.
>I didn't think I could feel much dumber until I tried working on
>GCC on RH Linux 6.1.  I am trying to learn C, and the book I
>am reading from to teach myself the process said I needed a
>compiler.  I found one in Linux, so I thought, great!
>
> Well, in trying to actually run the compiler to get through my first
lesson (hello, world), I can't figure out how to run GCC.

Your messge is a bit vague for me. Let's look into the problem:

irst of all, do you have an existing C program that you want to
compile, or are you asking how to write a C program? If the latter,
then your message was mis-addressed, because that email group is
for the people who are developing the compiler, NOT for those
who use it as a tool. Here's a stupid, do-nothing C program;
see Kernighan & Ritchie's "The C Programming Language"
for more simple examples and a reference manual for the language:

--- cut here -----

/* Test case  simple.c     by  bernecky@acm.org */
/* This is a very simple pointer user that should just work */

#include <stdio.h>
#include <string.h>

int
main (void)
{
int *p1;
int *p2;
int i;

int v1[5]={2,4,6,8,10};
int v2[5];

 p2=&v2[0];
 for (p1=&v1[0]; p1 < &v1[5]; p1++)
        {
         *p2=*p1;
         p2++;
        };

for (i=0; i<5; i++)
        {
         printf("v1[%d]=%d, v2[%d]=%d\n",i,v1[i],i,v2[i]);
        };

  return 0;
}



-- cut here ---

If you stuff the above text into a file called "simple.c"
and then do:

  gcc simple.c

you should get a file apeparing called (Don't ask me why -- it's
stupid, but that's what it does...)  a.out.
Now, if you type

a.out

you should see something like this:

v1[0]=2, v2[0]=2
v1[1]=4, v2[1]=4
v1[2]=6, v2[2]=6
v1[3]=8, v2[3]=8
v1[4]=10, v2[4]=10

The compiler examined the above simple.c  and produced a.out,
which is an x86 (in my case) program that is supposed to do the same
thing as simple.c.

If all the above makes sense and answers your questions, then
you need to go read some "Introductory C" books.
If not, as your next paragraphs suggest, then read on.


>I have looked at the howto and the man pages, and your home page,
>but can't figure out just how to do anything more complex than
>getting the version of GCC that is on my Linux box.

a. What DO you want to do?
b. What do you want to do that is "more complex"?

>I find the information confusing, with nothing simple that
>actually tells me how to use the application.

Excuse me for being pedantic, but gcc is not an application,
in my book. It's a compiler; we use compilers to build applications.
Think of it as a tool, much like a hammer. We use saws to cut wood
to build boats. Saws are tools, boats are products. In the same
way, compilers are tools and applications are products.

>I am new to Linux, so this doesn't help.
>I have all but given up hope on how to figure out just
>how to get it going.  I run the gcc command with <filename>.c and
            ^^^

What is "it"?

>I installed Linux and figured that learning the coding in Linux
>instead of Windows might help me get more adept at Linux.

You are not coding "IN" Linux or Windows; you are coding "for"
Linux or Windows in SOME language. In this case, the language
happens to be C.

>I am one of those morons who is used to the GUI and I
>probably deserve the RTFM response, but everything I have read on

Ah. You are perhaps suffering from a bad case of BillWare(tm),
where the toaster, sound system, mental floss, cat brush, and
bicycle are all "integrated" into a
seamless-whether-you-like-it-or-not whole. Or hole.
Linux ain't like that. If you want to build one of those
so-called integrated development environemnts, that's fine,
but gcc is merely one piece that would comprise such an animal.

There may be such a thing in Linux, perhaps running under an EMACS
shell,  but I don't know of one. Here's the order of battle:

a. write code using your favorite editor (vi, emacs...)
b. compile code with gcc
c. fix stupid errors and typos; go back to step b
d. execute code via typing    a.out
e. If it breaks it it isn't clear why, use the GNU debugger:
	gdb a.out
	run
	help

>this is written for someone that knows how to code in the
>first place.  There is no step 1, this is how you start
>the compiler or anything dumbed down that far.

You are correct. Big chance to get rich and become a famous author.

>Thanks.

You are quite welcome. Hope to see you back as a satisfied
user soon!

Bob

Robert Bernecky                  Snake Island Research Inc.
bernecky@acm.org                 18 Fifth Street, Ward's Island
+1 416 203 0854                  Toronto, Ontario M5J 2B9 Canada
http://www.snakeisland.com




More information about the Gcc mailing list