home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / gnu / gccdocs / gccstart.txt < prev   
Encoding:
Text File  |  1991-07-08  |  39.8 KB  |  372 lines

  1. @CB②PI⇧Fx0œF
  2.  
  3.  
  4.             Mike Dorman's "Quick Start" docs for the GNU C compiler, GCC.F
  5.  
  6.                                                                          
  7.  
  8.                                                                          
  9.                So you want to be a rock and roll star...Sorry, a Byrds
  10.  
  11.                                                                       
  12.           flashback, I apologize.
  13.  
  14.                                  
  15.                So you want to use GNU C.
  16.  
  17.                                         
  18.  
  19.                                         
  20.                                   GENERAL COMMENTS
  21.  
  22.                                                   
  23.  
  24.                                                   
  25.                Well, although GCC is a *very* good compiler--and free, to
  26.  
  27.                                                                          
  28.           boot--it could be called, rather charitably, "user-hostile." 
  29.  
  30.                                                                        
  31.           I'm writing this document in the hopes of de-mystifying the
  32.  
  33.                                                                      
  34.           process of setting-up and using it.  I won't make any warranty
  35.  
  36.                                                                         
  37.           that this document will save your sanity, help you sleep better,
  38.  
  39.                                                                           
  40.           promote world peace, or even not cause you to trash your hard
  41.  
  42.                                                                        
  43.           disk, so don't come crying to me if any of this happens.  That's
  44.  
  45.                                                                           
  46.           the official disclaimer, so let's get down to business.
  47.  
  48.                                                                  
  49.  
  50.                                                                  
  51.                The GNU C compiler is a wonderful thing, but it was written
  52.  
  53.                                                                           
  54.           on and developed for users of Unix (which is a registered
  55.  
  56.                                                                    
  57.           trademark of AT&T) and Unix variants, and so it doesn't
  58.  
  59.                                                                  
  60.           necessarily mesh with your ST all that well.  I'll try and show
  61.  
  62.                                                                          
  63.           you how to set it up to work from a command-line-interface (from
  64.  
  65.                                                                           
  66.           here on out, a "CLI") or from the desktop, but depending on your
  67.  
  68.                                                                           
  69.           system resources, one or the other or both may be out of the
  70.  
  71.                                                                       
  72.           question.
  73.  
  74.                    
  75.  
  76.                                  SYSTEM REQUIREMENTS
  77.  
  78.                                                     
  79.  
  80.                                                     
  81.                To begin with, you need *at least* 1MB of ram.  That's not
  82.  
  83.                                                                          
  84.           that stringent a requirement these days, at least not for semi-
  85.  
  86.                                                                          
  87.           serious development, but 1MB is also only going to allow you to
  88.  
  89.                                                                          
  90.           compile *really small* programs.  You best bet is with 2MB or
  91.  
  92.                                                                        
  93.           more of system ram--4MB is really neat, and you would probably
  94.  
  95.                                                                         
  96.           have enough space to have a ramdisk present for temporary files
  97.  
  98.                                                                          
  99.           (GNU C creates a *lot* of them).
  100.  
  101.                                           
  102.  
  103.                                           
  104.                Next, you need a hard-disk.  There's no way around it--the
  105.  
  106.                                                                          
  107.           program that actually *compiles* code is ~600K, so that did away
  108.  
  109.                                                                           
  110.           with nearly a whole floppy-disk's worth of space right there.  If
  111.  
  112.                                                                            
  113.           you don't have one, you ought to, you would really like it.  Come
  114.  
  115.                                                                            
  116.           back when you have one, because until you do, you're not going to
  117.  
  118.                                                                            
  119.           be able to use GCC at all.
  120.  
  121.                                     
  122.  
  123.                                     ✓✓✓GENERAL SETUP INFO
  124.  
  125.                                                    
  126.  
  127.                                                    
  128.                Assuming you have the hardware required, you need to set up
  129.  
  130.                                                                           
  131.           GCC.  The first setup I'll mention is that for CLI users--I
  132.  
  133.                                                                      
  134.           haven't used this in a while, so forgive any inaccuracies you may
  135.  
  136.                                                                            
  137.           find--tell me about them, though, since I will spend some time
  138.  
  139.                                                                         
  140.           updating this document, if necessary--I use GCC myself, and much
  141.  
  142.                                                                           
  143.           of this information is strictly experience-based.  If I'd had
  144.  
  145.                                                                        
  146.           this document, I would have been doing programming *many* months
  147.  
  148.                                                                           
  149.           before I actually started, because I wouldn't have had to spend
  150.  
  151.                                                                          
  152.           so much time sussing out the system.  People who intend to use
  153. œF
  154.  
  155.  
  156.           GNU C from GEM still need to read the next section on CLI-basedF
  157.  
  158.                                                                          
  159.           setup--there's some concepts discussed there that you still need
  160.  
  161.                                                                           
  162.           to be familiar with.
  163.  
  164.                               
  165.  
  166.                                       CLI SETUP
  167.  
  168.                                                
  169.  
  170.                                                
  171.                There are a bunch of CLIs around there, but some of them are
  172.  
  173.                                                                            
  174.           not acceptable to GCC--the biggest reason being that some
  175.  
  176.                                                                    
  177.           (notably PCOMMAND) force the command lines to uppercase, and GCC
  178.  
  179.                                                                           
  180.           uses lower-case parameters all the time.  I can personally
  181.  
  182.                                                                     
  183.           recommend GULAM, an excellent CLI with a MicroEmacs-based built-
  184.  
  185.                                                                           
  186.           in editing facility, and MUPFEL, the excellent CLI included with
  187.  
  188.                                                                           
  189.           GEMINI.
  190.  
  191.                  
  192.  
  193.                  ✓✓Once you've got your CLI in place and set up to reflect some
  194.  
  195.                                                                            
  196.           of your personal foibles, you need to start customizing it for
  197.  
  198.                                                                         
  199.           GCC.
  200.  
  201.               
  202.  
  203.                The first thing you need to do here is find your CLI's
  204.  
  205.                                                                      
  206.           equivalent of MS-DOS's AUTOEXEC.BAT.  For GULAM this is the file
  207.  
  208.                                                                           
  209.           GULAM.G.  For MUPFEL, this is MUPFEL.MUP.
  210.  
  211.                                                    
  212.  
  213.                                                    
  214.                Fire up your favorite editor, set to edit this file.  You
  215.  
  216.                                                                         
  217.           will need to set six environment variables.  Most shells use the
  218.  
  219.                                                                           
  220.           format:
  221.  
  222.                  
  223.  
  224.                  ✓✓setenv <variable name> <variable value>
  225.  
  226.                                                       
  227.  
  228.                                                       
  229.                The environment variables you will nedd to set are:
  230.  
  231.                                                                   
  232.  
  233.                                                                   
  234.                GCCEXEC
  235.  
  236.                       
  237.                GCC_EXEC_PREFIX
  238.  
  239.                               
  240.                GNULIB
  241.  
  242.                      
  243.                GNUINC
  244.  
  245.                      
  246.                TEMP
  247.  
  248.                    ✓✓✓✓PATH
  249.  
  250.                    
  251.  
  252.                                        GCCEXEC
  253.  
  254.                                               
  255.  
  256.                                               
  257.                GCCEXEC is the environment variable which points to the
  258.  
  259.                                                                       
  260.           executables of GNU C.  This variable requires that you give the
  261.  
  262.                                                                          
  263.           complete path to where the executables are store, and then append
  264.  
  265.                                                                            
  266.           "gcc-" to that path.  For my system-setup, you'd get:
  267.  
  268.                                                                
  269.  
  270.                                                                
  271.                setenv GCCEXEC g:\gnubin\gcc-
  272.  
  273.                                             
  274.  
  275.                                             
  276.                Modify the drive letter and the pathname as you see fit to
  277.  
  278.                                                                          
  279.           make it conform to your system.  This variable points to the
  280.  
  281.                                                                       
  282.           executables so GCC.TTP, the "compiler driver," can find them.
  283.  
  284.                                                                        
  285.  
  286.                                                                        
  287.                                    GCC_EXEC_PREFIX
  288.  
  289.                                                   
  290.  
  291.                                                   
  292.                GCC_EXEC_PREFIX seems to be functionally equivalent to
  293.  
  294.                                                                      
  295.           GCCEXEC.  In fact, it also has to have that silly "gcc-" appended
  296. œF
  297.  
  298.  
  299.           to the path, just as GCCEXEC does.  I haven't bothered to findF
  300.  
  301.                                                                         
  302.           out if these two variables are redundant.  For my system-setup
  303.  
  304.                                                                         
  305.           you'd end up with:
  306.  
  307.                             
  308.  
  309.                             
  310.                setenv GCC_EXEC_PREFIX g:\gnubin\gcc-
  311.  
  312.                                                     
  313.  
  314.                                                     
  315.                                        GNULIB
  316.  
  317.                                              
  318.  
  319.                                              
  320.                GNULIB is the environment variable that points to the object
  321.  
  322.                                                                            
  323.           libraries that contain the compiled startup and execution code
  324.  
  325.                                                                         
  326.           that GCC uses--for instance, the code that comprises the standard
  327.  
  328.                                                                            
  329.           input/output functions in the module "stdio."  It also points to
  330.  
  331.                                                                           
  332.           the files gcrt0.o and crt0.o, the two files that contain the
  333.  
  334.                                                                       
  335.           runtime startup code for every GNU C-compiled program.  Don't let
  336.  
  337.                                                                            
  338.           the tech talk confuse you--let's just say that these are *very*
  339.  
  340.                                                                          
  341.           necessary files.  In the GCC 1.40 release that I uploaded, all
  342.  
  343.                                                                         
  344.           these files were in the file LIBOLB68.LZH.  Without these files,
  345.  
  346.                                                                           
  347.           you're up the creek, so go get them if you don't already have
  348.  
  349.                                                                        
  350.           them.  For my system-setup, you'd have the following:
  351.  
  352.                                                                
  353.  
  354.                                                                
  355.                setenv GNULIB g:\gnulib
  356.  
  357.                                       
  358.  
  359.                                       
  360.                Note that this variable doesn't have to have any of the
  361.  
  362.                                                                       
  363.           silly postfixes that GCCEXEC and GCC_EXEC_PREFIX require.  It
  364.  
  365.                                                                        
  366.           *should not* end in a backslash ("\").
  367.  
  368.                                                 
  369.  
  370.                                                 
  371.                                        GNUINC
  372.  
  373.                                              
  374.  
  375.                                              
  376.                This variable tells GNU C where to find the header files for
  377.  
  378.                                                                            
  379.           the compiler.  These files are the ".h" files that you often see
  380.  
  381.                                                                           
  382.           refered to in the first lines of a program, like this:
  383.  
  384.                                                                 
  385.  
  386.                                                                 
  387.                #include <stdio.h>
  388.  
  389.                                  
  390.  
  391.                                  
  392.                These header files contain useful definitions of constants
  393.  
  394.                                                                          
  395.           your program may need to know (such as NULL), or prototypes for
  396.  
  397.                                                                          
  398.           various functions (such as printf--these prototypes allow the C
  399.  
  400.                                                                          
  401.           compiler to make sure that you aren't handing some bogus
  402.  
  403.                                                                   
  404.           arguments to a function).  They are *very* necessary, also.  In
  405.  
  406.                                                                          
  407.           fact, everything I discuss here is pretty important--this is the
  408.  
  409.                                                                           
  410.           stuff I *know* you need--anything else, well, its omission hasn't
  411.  
  412.                                                                            
  413.           bitten me yet.
  414.  
  415.                         
  416.  
  417.                         
  418.                For my system-setup, GNUINC is defined like this:
  419.  
  420.                                                                 
  421.  
  422.                                                                 
  423.                setenv GNUINC g:\gnuinc
  424.  
  425.                                       
  426.  
  427.                                       
  428.                The syntax is the same as GNULIB, not requiring any of the
  429.  
  430.                                                                          
  431.           funky little additions that GCCEXEC and GCC_EXEC_PREFIX do.
  432.  
  433.                                                                      
  434.  
  435.                                                                      
  436.                                         TEMP
  437.  
  438.                                             
  439.  
  440.                                             
  441.                As I said before, GCC produces *lots* of temporary files, so
  442.  
  443.                                                                            
  444.           that the various peices of the compiler can communicate and pass
  445. œF
  446.  
  447.  
  448.           their processed information to the next link in the greatF
  449.  
  450.                                                                    
  451.           compiler-chain.
  452.  
  453.                          
  454.  
  455.                          
  456.                GNU C *deperately* needs to be told where to put these
  457.  
  458.                                                                      
  459.           temporary files--otherwise it'll probably attempt to stash them
  460.  
  461.                                                                          
  462.           in places that don't exist on your system--or maybe you do have
  463.  
  464.                                                                          
  465.           a /gnu/gcc/cross-compile/temp directory, and I don't know what
  466.  
  467.                                                                         
  468.           I'm talking about.  :^)
  469.  
  470.                                  
  471.  
  472.                                  
  473.                If you have a ramdisk, this is probably the place to put
  474.  
  475.                                                                        
  476.           your temporary files, as doing that will make GNU C *fly*. 
  477.  
  478.                                                                      
  479.           Unfortunately, that upgrade to 4MB is a ways away for me, and
  480.  
  481.                                                                        
  482.           since I need most of my 2.5 MB for GNU C to work in, I have to
  483.  
  484.                                                                         
  485.           send temporary files to my hard drive.  For my system-setup, TEMP
  486.  
  487.                                                                            
  488.           is set to:
  489.  
  490.                     
  491.  
  492.                     
  493.                setenv TEMP g:
  494.  
  495.                              
  496.  
  497.                              
  498.                Notably, you *cannot* have this variable end in a backslash
  499.  
  500.                                                                           
  501.           and still expect GCC to function.  If TEMP is set incorrectly,
  502.  
  503.                                                                         
  504.           you'll get some interesting, but somewhat obscure, error messages
  505.  
  506.                                                                            
  507.           when you try to compile.  You might want to try it, just so
  508.  
  509.                                                                      
  510.           you'll see them, so you can recognize them in the future, because
  511.  
  512.                                                                            
  513.           this one variable will probably bite you more than any other.
  514.  
  515.                                                                        
  516.  
  517.                                                                        
  518.                                         PATH
  519.  
  520.                                             
  521.  
  522.                                             
  523.                This may be the most important environment variable of them
  524.  
  525.                                                                           
  526.           all.  Despite the existence of GCCEXEC and GCC_EXEC_PREFIX, GNU C
  527.  
  528.                                                                            
  529.           still uses the old, reliable PATH variable to find some of its
  530.  
  531.                                                                         
  532.           files.  For my system-setup I have PATH set up this way:
  533.  
  534.                                                                   
  535.  
  536.                                                                   
  537.                setenv PATH c:\;g:\gnubin
  538.  
  539.                                         
  540.  
  541.                                         
  542.                There are some interesting things about PATH that you should
  543.  
  544.                                                                            
  545.           know.  First, GEM *really*, **really** wants your boot device to
  546.  
  547.                                                                           
  548.           be the first entry in PATH, hence the "c:\" as my first entry. 
  549.  
  550.                                                                          
  551.           The second item is this--GEM uses PATH to help itself find
  552.  
  553.                                                                     
  554.           resource (.rsc) files for GEM applications.  If you set you path
  555.  
  556.                                                                           
  557.           correctly, you can move *all* of your resource files to one
  558.  
  559.                                                                      
  560.           directory--possibly eliminating some clutter.  The last comment
  561.  
  562.                                                                          
  563.           I'll make is a little more general--PATH, GNULIB and GNUINC can
  564.  
  565.                                                                          
  566.           all point to more than one particular directory.  All you have to
  567.  
  568.                                                                            
  569.           do is separate the different directories with commas (",") or
  570.  
  571.                                                                        
  572.           semicolons (";").  BE WARNED!  In GULAM, and I think MUPFEL,
  573.  
  574.                                                                       
  575.           semicolons are used to "stack" commands, so you will need to
  576.  
  577.                                                                       
  578.           enclose any variables which include them in quotes.  For example:
  579.  
  580.                                                                            
  581.  
  582.                                                                            
  583.                setenv PATH "c:\;g:\gnubin"
  584.  
  585.                                           
  586.  
  587.                                           ✓✓✓✓GEM SETUP
  588.  
  589.                                                
  590.  
  591.                                                
  592.                You have probably taken the harder road for the nonce--with
  593.  
  594.                                                                           
  595.           the right tools (which I should be able to upload to GEnie, RSN,
  596. œF
  597.  
  598.  
  599.           just as soon as Ian Lepore decides that they've been beta-testedF
  600.  
  601.                                                                           
  602.           enough), programming from the desktop can be a breeze, but right
  603.  
  604.                                                                           
  605.           now, it requires some special tools that aren't as user-friendly
  606.  
  607.                                                                           
  608.           as the ones I'm using.
  609.  
  610.                                 
  611.  
  612.                                 
  613.                First, you need some way to set environment variables.  As
  614.  
  615.                                                                          
  616.           the preceeding text (marked for CLI users, but you did read it,
  617.  
  618.                                                                          
  619.           didn't you, like I recommended?) might indicate, environment
  620.  
  621.                                                                       
  622.           variables are what GNU C lives and dies by.  Unfortunately,
  623.  
  624.                                                                      
  625.           though GEM will use environment variables, it doesn't give you an
  626.  
  627.                                                                            
  628.           easy way to set them.
  629.  
  630.                                
  631.  
  632.                                
  633.                NeoDesk, by Gribnif Software, supports them, and if you
  634.  
  635.                                                                       
  636.           don't have that, there's an auto-folder program called ENVIRON
  637.  
  638.                                                                         
  639.           (it should be on GEnie) which will set them as well.  You need to
  640.  
  641.                                                                            
  642.           get one of these programs, read the documentation and set the
  643.  
  644.                                                                        
  645.           variables that I spent the last few pages describing, but in
  646.  
  647.                                                                       
  648.           accordance with your setup, of course.
  649.  
  650.                                                 
  651.  
  652.                                                 
  653.                               BASIC COMPILING EXAMPLES
  654.  
  655.                                                       
  656.  
  657.                                                       
  658.                Well, once you've gotten all those variables set, you're
  659.  
  660.                                                                        
  661.           ready to start compiling stuff.
  662.  
  663.                                          
  664.  
  665.                                          
  666.                If you're using a CLI, you'll need to type gcc (don't hit
  667.  
  668.                                                                         
  669.           enter yet!), and then wait a minute while I attend to the GEM
  670.  
  671.                                                                        
  672.           people.  If you're using GEM, you need to double-click on
  673.  
  674.                                                                    
  675.           GCC.TTP, so that it gives you a dialog box so you can input
  676.  
  677.                                                                      
  678.           command line options.
  679.  
  680.                                
  681.  
  682.                                
  683.                There are a bunch of command line options, all well-
  684.  
  685.                                                                    
  686.           documented in the GCC ST documentation.  By the time you need the
  687.  
  688.                                                                            
  689.           others, though, you will probably know enough to figure them out
  690.  
  691.                                                                           
  692.           for yourself (a cop out, I know, but it's late, and I promised
  693.  
  694.                                                                         
  695.           myself that I'd write this before I went to bed).  For the
  696.  
  697.                                                                     
  698.           moment, I'll show you some of the simpler, but most important,
  699.  
  700.                                                                         
  701.           ones.
  702.  
  703.                
  704.  
  705.                For example, let's say you have the file wombat.c, and you
  706.  
  707.                                                                          
  708.           want to compile it.  You would probably want to type the
  709.  
  710.                                                                   
  711.           following command line in (omitting the gcc at the beginning if
  712.  
  713.                                                                          
  714.           you're using the desktop):
  715.  
  716.                                     
  717.  
  718.                                     
  719.                gcc -v -O -o wombat.ttp wombat.c
  720.  
  721.                                                
  722.  
  723.                                                
  724.                The "-v" parameter specifies *verbose* mode.  This means
  725.  
  726.                                                                        
  727.           that gcc and all the compiler programs will indicate that they're
  728.  
  729.                                                                            
  730.           running, and give you the version numbers, and such.  This isn't
  731.  
  732.                                                                           
  733.           necessary, but it's useful, just to watch the process involved.
  734.  
  735.                                                                          
  736.  
  737.                                                                          
  738.                The "-O" parameter specifies *optimize* mode.  In this mode,
  739.  
  740.                                                                            
  741.           GCC will try to produce the smallest, fastest code it can. 
  742.  
  743.                                                                      
  744.           Again, this isn't essential, but it *is* useful.
  745.  
  746.                                                           
  747. œF
  748.  
  749.  
  750.                The "-o" parameter (remember, this stuff is case-sensitive,F
  751.  
  752.                                                                           
  753.           which means using GCC from the desktop with TOS 1.0 *will not*
  754.  
  755.                                                                         
  756.           work) has an attachment--in this case, "wombat.ttp".  This
  757.  
  758.                                                                     
  759.           parameter tells GCC what the output file's name will be.  It
  760.  
  761.                                                                       
  762.           isn't necessary, but without it, GCC will produce a file named
  763.  
  764.                                                                         
  765.           "a.out".  While this will be a perfectly fine executable, since
  766.  
  767.                                                                          
  768.           it doesn't end in .tos, .ttp or .prg, TOS won't know it's meant
  769.  
  770.                                                                          
  771.           to be executable, and will, therefore, stare at you blankly if
  772.  
  773.                                                                         
  774.           you try to run it.
  775.  
  776.                             
  777.  
  778.                             
  779.                The last parameter, "wombat.c", tells GCC what file to
  780.  
  781.                                                                      
  782.           compile.  You can include a path, such as "d:\wombat\wombat.c" if
  783.  
  784.                                                                            
  785.           you choose--this is most useful from GEM, since you may not have
  786.  
  787.                                                                           
  788.           the source file in the same directory as GCC.
  789.  
  790.                                                        
  791.  
  792.                                                        
  793.                All this, though, only shows you how to do text-based, non-
  794.  
  795.                                                                           
  796.           GEM programs.  Thos are fine for IBM users, but we've got a
  797.  
  798.                                                                      
  799.           built-in GUI, so you'll probably want to write GEM programs
  800.  
  801.                                                                      
  802.           before long.  Compiling those requires more parameters, such as
  803.  
  804.                                                                          
  805.           in the example:
  806.  
  807.                          
  808.  
  809.                          
  810.                gcc -v -O -o wombat.prg wombat.c -lgem
  811.  
  812.                                                      
  813.  
  814.                                                      
  815.                This command line differs from the first in two respects. 
  816.  
  817.                                                                          
  818.           First, the target file is named .prg, so it will run with GEM and
  819.  
  820.                                                                            
  821.           mouse support and all that.
  822.  
  823.                                      
  824.  
  825.                                      
  826.                The second difference is the "-lgem" parameter.  This tells
  827.  
  828.                                                                           
  829.           the compiler to link in the library with all the object files
  830.  
  831.                                                                        
  832.           that support GEM calls--probably named "gem.olb." Actually, the
  833.  
  834.                                                                          
  835.           parameter is "-l", with "gem" denoting the name of a compiler
  836.  
  837.                                                                        
  838.           library--one of those pesky, huge, ".olb" files.
  839.  
  840.                                                           
  841.  
  842.                                                           
  843.                Assuming that you'e got everything set up right, you should
  844.  
  845.                                                                           
  846.           have a program on your hands.  Run and enjoy!
  847.  
  848.                                                        
  849.  
  850.                                                        
  851.                                MORE ADVANCED COMPILING
  852.  
  853.                                                       
  854.  
  855.                                                       
  856.                There's one other thing that you ought to know about.  One
  857.  
  858.                                                                          
  859.           of C's features is the ability to compile modules of programs
  860.  
  861.                                                                        
  862.           separately, and then link those together.  In this way, you can
  863.  
  864.                                                                          
  865.           avoid having one *huge* ".c" file, by putting routines in other,
  866.  
  867.                                                                           
  868.           smaller, ".c" files.
  869.  
  870.                               
  871.  
  872.                               
  873.                To do this properly, there are two steps you have to go
  874.  
  875.                                                                       
  876.           through.
  877.  
  878.                   
  879.  
  880.                   ✓✓✓First, you have to compile the separate modules into ".o"
  881.  
  882.                                                                         
  883.           files.  You do this with the command line:
  884.  
  885.                                                     
  886.  
  887.                                                     
  888.                gcc -c -v -O wombat.c
  889.  
  890.                                     
  891.  
  892.                                     
  893.                In this example, the "-c" flag tells the compiler to just
  894.  
  895.                                                                         
  896.           compile the file, not to link it--which mashes it in with a
  897. œF
  898.  
  899.  
  900.           bunch of other files, an ugly process which is necessary toF
  901.  
  902.                                                                      
  903.           create an executable file.  This command line *should* produce a
  904.  
  905.                                                                           
  906.           file with the same name as the ".c" file, but an extension of
  907.  
  908.                                                                        
  909.           ".o."
  910.  
  911.                
  912.  
  913.                Once you have done this procedure to all your smaller
  914.  
  915.                                                                     
  916.           routines, you then need to tell the compiler to link them to your
  917.  
  918.                                                                            
  919.           main program module.  You use this command line for that:
  920.  
  921.                                                                    
  922.  
  923.                                                                    
  924.                gcc -v -O -o wombat.prg wombat.c smut.o lewd.o -lgem
  925.  
  926.                                                                    
  927.  
  928.                                                                    
  929.                This will automagically link the files "smut.o" and "lewd.o"
  930.  
  931.                                                                            
  932.           (or whatever the names of the object files you created in the
  933.  
  934.                                                                        
  935.           above example are) into the file wombat.prg.  It will then link
  936.  
  937.                                                                          
  938.           in any necessary files from the GEM library.  Hopefully, these
  939.  
  940.                                                                         
  941.           steps will produce your first modularly-coded C program.
  942.  
  943.                                                                   
  944.  
  945.                                                                   
  946.                                      FINAL NOTES
  947.  
  948.                                                 
  949.  
  950.                                                 
  951.                Well, I've listened to the same CD four times typing this. 
  952.  
  953.                                                                           
  954.           I hope there's not too many inaccuracies, typos, blatant lies or
  955.  
  956.                                                                           
  957.           spelling mistakes, but I'm sure there will be--it's late and I'm
  958.  
  959.                                                                           
  960.           sleepy.  In the event that you find something unclear,
  961.  
  962.                                                                 
  963.           confusing, too brief or outright wrong, please leave mail for me
  964.  
  965.                                                                           
  966.           at any of these electronic addresses--I want to make this
  967.  
  968.                                                                    
  969.           document easy to use, and helpful, to boot, and am willing to
  970.  
  971.                                                                        
  972.           revise it if it doesn't start out that way:
  973.  
  974.                                                      
  975.  
  976.                                                      
  977.                MDORMAN1@UA1VM.UA.EDU on the Internet.
  978.  
  979.                                                      
  980.                mike.dorman on BIX.
  981.  
  982.                                   
  983.                M.DORMAN2 on GEnie.
  984.  
  985.                                   
  986.  
  987.                                   
  988.                On BIX I am active in the atari.st conference, and messages
  989.  
  990.                                                                           
  991.           left in the c.language topic will get to me, as will e-mail.  On
  992.  
  993.                                                                           
  994.           GEnie, messages left in the GNU C topic--I don't remember the CAT
  995.  
  996.                                                                            
  997.           and TOP numbers--will get to me, as will e-mail.
  998.  
  999.                                                           
  1000.  
  1001.                                                           
  1002.                Please remember, though, that this isn't meant to be a
  1003.  
  1004.                                                                      
  1005.           tutorial on programming in C on the ST--better people than I have
  1006.  
  1007.                                                                            
  1008.           written entire books about that.  This file, will, I hope, make
  1009.  
  1010.                                                                          
  1011.           it easier to use GNU C for this purpose, though.
  1012.  
  1013.                                                           
  1014.  
  1015.                                                           
  1016.                Mike.
  1017.  
  1018.                     
  1019.  
  1020.                     
  1021.                Typed between the hours of 11 pm July 3, 1991 and 1am July
  1022.  
  1023.                                                                          
  1024.           4, 1991 on WordPerfect for the ST.  All the spelling errors are
  1025.  
  1026.                                                                          
  1027.           the computer's fault.
  1028. P