home *** CD-ROM | disk | FTP | other *** search
/ APDL Public Domain 1 / APDL_PD1A.iso / program / c / gnu_c / getstarted / GetStarted
Encoding:
Text File  |  1995-02-28  |  14.9 KB  |  287 lines

  1. Notes: GETTING STARTED  - Graham Seale  22-Oct-1994
  2. Note 27-Feb 1995 This file now requires modification - lots has changed! - GS
  3.  
  4. THE BIG DUMMY'S GUIDE TO USING GCC 2.4.5 from A.P.D.L
  5.  
  6. What you really need to do to get !GCC to compile a real C sourcefile. This note
  7. is for ABSOLUTE BEGINNERS, and anyone else, who (like me), are not among those
  8. who can breeze through the "Manuals" in !GCC.Docs and have the whole lot up and
  9. running in half an hour. This is my list of fixes to at least get it to run.
  10. Then - if you like, you can embellish and augment the approach until you have a
  11. complete whizz bang multitasking desktop development environment. This is
  12. just stage 0.5 or something. When you are an expert, you can strip this note
  13. down to be a model of brevity!.
  14.  
  15. Before we begin, be assured !GCC is INCREDIBLY GOOD VALUE. It outperforms the
  16. Acorn, (and other) products I am told. Read ALL of this file before taking the plunge.
  17. ____________________________________________________________________________________              
  18.  
  19. Be cautious about the MANUALS. The gcc, cpp and invoke documents assume you are
  20. using UNIX or DOS conventions which allow the compiler to identify the type of
  21. file by its extension. eg. <file>.c or <file>.h etc. Of course, this cannot work
  22. in RiscOS. Instead , the subdirectory containing the file is to be "c." or "h."
  23. or "s." or whatever. In my first experiences, it was not enough that the
  24. sourcefile was in a directory called c. I got around it by using the -x option
  25. to force the compiler to recognise the file as a C source. My  command line
  26. includes the fragment
  27.                "gcc -x c -<other options> etc".
  28. ____________________________________________________________________________________              
  29.  
  30. Note the "manuals" texts are liberally sprinkled with control character text
  31. meaningful only to a wordprocessor called "Tex" or "Texi". As it happens, the UNIX
  32. based Tex text formatter is available free at nearly all points where GNU software can
  33. be sourced. Very likely, like all GNU software, it could be ported to the Archimedes.
  34. I have yet to explore a little further to find it. but it is an obvious thing to include
  35. when distributing GCC - so we can read the manuals! Without Tex, it is just about
  36. possible to disentangle text by selective deletion (misery!). THEN you need to
  37. translate it into RiscOS-Speak (more misery!). This situation will change in time.
  38. _____________________________________________________________________________________
  39.  
  40. 1.0   The !GCC Files as supplied (from David Holden's A.P.D.L.) B194.
  41.  
  42.       <Shift> plus a double - click will  to reveal a directory containing the
  43. files:
  44.  
  45.       !Boot
  46.       !Run
  47.       !Sprites
  48.       !Help
  49.       !Readme                and also the directories:
  50.       
  51.       bin
  52.       gcc
  53.       gpp
  54.       UnixLib
  55.       
  56.       Then, from a second disc, you get:
  57.   
  58.       docs    -    a directory of documentation
  59.       DrLink  -    a directory of linker files ...ESSENTIAL!
  60.       RiscLib -    a directory stuffed with potentially useful stuff....CAUTION
  61.       RiscOS  -    a directory of documentation about an earlier !GCC...CAUTION.
  62.       
  63. You don't need the RiscLib or RiscOS directories yet. They have their own
  64. hazards, and come from an earlier version of GCC for Archimedes as tweaked into
  65. life by Thomas Abey and friends in Germany. Don't chuck them out, there is good
  66. stuff there. But for now, leave them strictly alone.
  67.       
  68. There may come a time when this file you are reading is also included among the
  69. group - who knows. Anyway, to get things going, read on.
  70. ______________________________________________________________________________
  71.  
  72. 1.1   Firstly, YOU NEED TO FIX THE !Boot and !Run FILES !!!!!!
  73.       
  74.       You will have noticed that as soon as you double - clicked !GCC, it simply
  75.       opened up its directory window. The !Boot file will have previously set up
  76.       variables called Run$Path, Unix$Path, GCC$Path and GPP$Path. This happens
  77.       as soon as the !GCC directory and its !Boot file is seen by the Filer.
  78.       
  79.       When !GCC is double - clicked, the !Run file (among other things), runs
  80.       the !Boot file all over again. This has the effect of repeatedly extending
  81.       Run$Path with the same GCC$Path ad nausium. According to the book the 
  82.       correct way to prevent this happening is done thus:-
  83.       
  84. a)    In the !Boot file, find the line
  85.       
  86.       Set Run$Path <Run$Path>,<Obey$Dir>.bin.
  87.       
  88.       and then disable it either by turning it into a comment by inserting a
  89.       | at the beginning of the line, or by deleting it altogether.
  90.       
  91. b)    Replace it with the line
  92.  
  93.       If "<GCC$Path>" = "" then Set Run$Path <Run$Path>,<Obey$Dir>.bin.
  94.       
  95.       This will ensure the pathname is appended once, and once only. If you want to
  96.       invoke GCC from elsewhere (say from a RAMDISK), then you will have to ensure
  97.       Run$Path gets extended to point there.
  98.       
  99. c)    In the !Run file, the line that re-runs the !Boot file seems unnecessary.
  100.       I disabled that line, while accepting there may be situations when there
  101.       is a need to restore the Filer_OpenDir, and UnixFS$/tmpvariables.
  102.       Filer_OpenDir, and UnixFS$/tmp are set here.
  103.       
  104.       At this stage, simply typing gcc at the command line, or from a command
  105.       script in an Obey file, will invoke the compiler, and provoke the message
  106.       "no input files specified". 
  107.       
  108. d)   Any compiler output appears in a window cut into the desktop screen, and 
  109.      freezes the desktop until you press <Space> or click the mouse to regain
  110.      control, whence, the whole screen re-draws. If you  use the !ZAP editor
  111.      from Dominic Symes, you have the nicer option of creating a "TaskExec" file
  112.      (type FD6) to contain the line:- 
  113.  
  114.         gcc -<options> -<more options> <sourcefile_path>.<sourcefile_name>
  115.  
  116.      The effect is to feed the compiler output into a !ZAP editor screen window.
  117.      The text is much tidier if !ZAP was already on the iconbar.
  118. ____________________________________________________________________________________
  119.      
  120. 1.2   WHERE TO PUT THE EXECUTABLES.
  121.  
  122.       The executables are all those APPs in the !GCC.bin directory. You can
  123.       leave them just where they are. Once Run$Path has been set by the !Boot
  124.       file the "gcc"command will find them. You COULD  move them to the main
  125.       system library, where the path will always find them. I run a RiscPC600,
  126.       and the executables proper home is ADFS::HardDisc4.$.!Boot.Library. Other
  127.       machines no doubt have their equivalent. I chose to leave the C Apps in
  128.       !GCC.bin, until I learned more about them. BE AWARE THERE IS ONE MORE
  129.       EXECUTABLE CALLED "LINK" WHICH NEEDS TO BE PRESENT. More about this later.
  130.  
  131. ___________________________________________________________________________________
  132.  
  133.  1.3  GCC NEEDS TO BE ABLE TO FIND THE SOURCE FILE.
  134.  
  135.        There is much given in the gcc and invoke documentation about "defaults" 
  136.        for where to find sources, headers, etc, all driven by the FILENAME
  137.        EXTENSION. Since this concept does not apply in RiscOS, the !GCC.ReadMe
  138.        file says:
  139.        
  140.        "GCC uses the same assumptions as norcroft CC, with C sources held in the
  141.        '.c' subdirectory and header files held in the '.h' subdirectory, with
  142.        C++ sources held in the '.cc' subdirectoy. By default, GCC will compile,
  143.        assemble and link the supplied sources.
  144.        For most of the details for using GCC see the file invoke_texi."
  145.        
  146.        In practice, (no doubt also in my ignorance), I have NOT found this to be
  147.        the case. It seems that if the compiler is instructed to make object or
  148.        assembler files without linking, it will create '.o' or '.s' sub - 
  149.        directories and put the output there. But it steadfastly refused to
  150.        believe my C source was of the correct format until I forced the issue
  151.        with a  -x c in the command. There is so much that the ReadMe file left
  152.        unsaid. Catch22 is that you need to buy the Norcroft compiler to become
  153.        familiar with "Norcroft assumptions", so that you can use !GCC. This is
  154.        example of the yawning gap that newcomers face.
  155.        
  156.        The path to the SourceFile needs to be correct in the argument.
  157.        for example:-
  158.        
  159.        gcc -<option> -<another_option> -<and_so_on> <path>.<c_source_textfile>
  160. ________________________________________________________________________________
  161.     A TINY TESTBED OF OBEY FILES - HOW TO ISSUE THE COMMAND
  162.  
  163. a)    You COULD, if you liked, press F12 and go back to BBC- speak, setting
  164.     paths, and driving it all from the command line. I cannot think of anything
  165.     more objectionable, but some people would not have it any other way.
  166.     Imagine typing out that command line every time.
  167.     
  168. b)    Slightly better, but hardly fun, is to stay in the desktop, but still drive
  169.     the command line by selecting Task Window (^F12 or find it with a menu click
  170.     under the green Acorn.
  171.     
  172. c)    You might be able to compose your C programs using a clever editor like
  173.     Dominic Symes' !Zap. You can configure the thing to invoke the compiler from
  174.     within the edit window using an appropriately set up function key macro. I might
  175.     try this soon.
  176.     
  177. d)    You could use a combination of Obey and TaskObey files, as a simple way of setting
  178.     up the process, and getting started. Look in the Example directory to find !Compile_C
  179.     and  !Run_C. Use <shift><double click> and take a look at them. Note how the current
  180.     directory is made to point at where the source is. Note that the Obey file called !Here
  181.     (in the c directory) will do the same thing, if you want to issue the gcc command at
  182.     the command line. !Here is not at all necessary if you had set the GCC  off by running
  183.     !Compile_C. More on this in 2.3 .
  184.     
  185.     While it is compiling, a Task Window opens, showing the compiler output, error messages
  186.     etc. and when done, a !RunImage file appears next to the source. Invoking the !RunImage
  187.     by double clicking on it will cut a window into the desktop, and run within (fast).
  188.     Using !Run_C opens a TaskWindow, and runs !RunImage within, (slower, but nicer).
  189.     
  190. e)    Note the source is nameed c_source, (it can be whatever temporary name takes your fancy,
  191.     so long as it is the same as the name in the !Compile_C).
  192.     
  193. f)    The !Here file, placed in the same directory as the source, and double clicked , is
  194.     just a cute way of setting the current directory to the same as the source.
  195.     Then, you can avoid the long <path> in the command line. You can get away with just
  196.     the source filename.  Clever clogs will set up environment variables (like C_Source$Path
  197.     or something similar instead. Do all that later. There are more serious hurdles yet.
  198.  
  199. ________________________________________________________________________________
  200.  
  201. 2.1  YOU NEED A BIG CHUNK OF MEMORY! 
  202.     
  203.      Either use the Task Manager to extend the allocation "Next" to about 2000K
  204.      or use the statement WimpSlot -min 1800K -max 2400K.  I found 1200K was not
  205.      enough, and 1432K was OK, as tried out on a trivial 4-line program.
  206.      Without the memory allocated, various compiler stages will complain about
  207.      being unable to create certain "/tmp" files, and later stages will complain
  208.      about being unable to find and use them. The demand for memory goes in the
  209.      command line obey (or TaskObey) file, NOT into !GCC boot or run files. This
  210.      is a fine point on which my present knowledge founders, but it seems to work.
  211.      I shall test the variants later.
  212.      
  213.      Apparently it is due to the structure of the "stack under UnixLib".
  214.      and "GCC is unable to extend its wimpslot, therefore you will have to set it to
  215.      the required size". The ReadMe file suggests 2 to 3 Meg
  216.      
  217.      I used and Obey file called c_setup to make a RAMDISK, copy the essential
  218.      bits of !GCC into it, and set up a couple of directories inside exactly as in
  219.      the example, with TaskObey files to run things. If you have enough memory, you
  220.       can experience fast, silent compiling with no hard disc activity at all.
  221.       There seems no perceptible advantage to this but it depends what you ask the
  222.       program to do. Asking for a hard disc access in a 30,000 loop WILL slow you
  223.       down a bit.
  224.  
  225. ________________________________________________________________________________
  226.      
  227. 2.2  YOU NEED A LINKER! (Read this bit carefully)
  228.  
  229.      A linker is not normally supplied with !GCC. Fortunately,the second
  230. A.P.D.L. disc has DrLink on it. In the DrLink directory you should find:
  231.  
  232. DDE          -    A directory containing:
  233.                                !DrLink
  234.                                 Readme
  235.  
  236. DrLink       -    An executable APP file <----  THIS IS THE ONE YOU NEED!
  237. DrLink_doc   -    The largest documentation file.
  238. Features     -    A crisp list of DrLink's abilities.
  239.  
  240. Copy the executable APP file called Drlink into !GCC.bin. Then, rename
  241. the copy in !GCC.Bin to "link". (ie The APP is <path>.!GCC.bin.link ).
  242.  
  243. Advanced users can later get to grips with the DDE.!Drlink program (with
  244. screwdriver and spanner icon). When you need to use the linker independently of
  245. the compiler, this is where you might come. For now we just need to raid the main
  246. APP from Drlink to give GCC a linking capability.
  247.  
  248. _______________________________________________________________________________
  249.  
  250. 2.3   THE COMMAND LINE   -   (or COMMAND SCRIPT in Obey or TaskExec Files)
  251.  
  252.           The COMMAND LINE needs some special things in it as a norm.
  253.  eg the -v switch, meaning "verbose - lets have lots of info back from the
  254. compiler as to how things are going".
  255.  
  256. The -O option to "optimise" - recommended to reduce the amount of extra code.
  257. Note that it is a capital "O".
  258.  
  259. The -S option will instruct to stop after compilation proper, but not to
  260. continue into assembly or linking. It will create a text file of assembler
  261. language and put it into a directory called "s", which it will create if it does
  262. not already exist.  There are dozens of options to amuse and confuse you. The
  263. command script I used to run a trivial program reads:-
  264.  
  265.              WimpSlot -min 1800K -max 2400K
  266.              gcc -O -v -x c Trivial_C
  267.  
  268. The result is the creation of a !Runimage executable in the same directory as
  269. your source. Double clicking it will run your program, or you can invoke it from
  270. other command script files if you wish. 
  271.  
  272. _________________________________________________________________________________
  273. 2.4
  274.  
  275. You may expect even a trivial program to generate about 30K of code. Quite a lot of
  276. this will be system error messages, traps, checks, etc. which is the same for all the
  277. programs, whatever their size.
  278. ___________________________________________________________________________________
  279.  
  280. It all seems very easy when you already know. For those experts who are now
  281. about to fall about laughing, all the above was dug out the hard way, after many
  282. attempts to winkle out the "cogniscienti" had failed. Either they were off to
  283. better things, or did not care to impart their knowledge. Since not all of us cut
  284. their teeth on a BBC model B, and worked up from there, this note is offered
  285. in the hope it will help some who are like me.
  286.  
  287.                        **********  FIN  ***********