home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / djgpp / djgpp.faq < prev    next >
Text File  |  1994-03-07  |  14KB  |  258 lines

  1. Q: What's the minimum set of .zip files I need for compiling programs?
  2. A: djeoeXXX, djdevXXX, gccXXXbn, gasXXXbn, and bnuXXbn are required.  The
  3.    remainder are for additional functionality.  Note that the version
  4.    numbers do not neccessarily match between FSF programs (gas and gcc)
  5.    and my programs (go32).  You'll also need bsnXXXbn for bison and
  6.    flxXXXbn for flex, where XXX is the version number.
  7.    
  8.    Note that C++ requires gppXXX.zip, and ObjectiveC requires objcXXX.zip.
  9.    The C++ library includes obstacks, alloca, and regex, so you need to
  10.    get gppXXX.zip to use them (libgpl.a)
  11.  
  12. Q: What about documentation?
  13. A: Get txiXXX.bn, which includes INFO.EXE.  Unpack it and run "info".  It
  14.    will bring up a (hopefully) self-explanatory online help system.
  15.  
  16.    For go32 and programs I wrote, get djdocXXX.zip, which includes the
  17.    data files for the online help system.
  18.  
  19.    For the FSF utilities, djgpp includes three files each.  Example:
  20.     gcc254bn.zip - binaries & source diffs for gcc 2.5.4
  21.     gcc254dc.zip - documentation for gcc 2.5.4
  22.     gcc254sr.zip - original FSF sources for gcc 2.5.4
  23.  
  24.    (Some sources are too big, and are split into multiple zips, all
  25.    of which must be unzipped to get a complete source distribution:
  26.         gcc254s1.zip
  27.         gcc254s2.zip
  28.         gcc254s3.zip
  29.    All sources are shipped in ready-to-build form.  The diffs in
  30.    the diffs directory have already been applied.)
  31.  
  32. Q: How do I find out what go32 is doing?
  33. A: The first thing to do is run "go32".  It will give you gobs of
  34.    information about what it knows about your system and itself.
  35.    Next, set the "topline" flag in the GO32 environment varable
  36.    (see the README) and watch the top line of your screen.  The
  37.    info there tells you something about what the program is doing.
  38.  
  39. Q: I get errors I can't figure out when I try to compile something.
  40. A: The best way to figure out what's going wrong with gcc is to
  41.    use the "-v" switch.  For example, if you run "gcc -v hello.c"
  42.    (assuming you have hello.c), it will tell you all the programs
  43.    it is running.  Then, you can see which program caused the
  44.    error.  The most likely cause of errors relating to missing
  45.    programs is that you haven't unpacked the zip file with
  46.    one of the compiler passes or utilities on it. 
  47.  
  48. Q: Why do I get so many unresolved symbols when linking C++ programs?
  49. A: The C++ libraries are not in libc.a, which is the only default
  50.    library.  You must use a command like this:
  51.        gcc -o prog prog.o -lgpp -lm
  52.    Note that some C++ classes use math routines, so the -lm should be
  53.    given after the -lgplus.  If you don't link with -lgpl or -lgpp,
  54.    you won't include any GPL code in your application.  You may not
  55.    need all of these libraries for your program. 
  56.  
  57. Q: How do I debug my programs?
  58. A: First, remember to use the -g switch when you compile.  This puts debugging
  59.    information into your executable.  Then, to debug the program, use a
  60.    command line like this:
  61.       go32 -d edebug32 myprog
  62.    "edebug32" is the external debugger.  See the file "edebug32.doc" for
  63.    information on the debugger commands.  Note: if you are running in a
  64.    DPMI environment, you must use "ed32-dpmi" instead of "edebug32".  Go32
  65.    normally searches relative to the current directory, then from it's own
  66.    directory, then the PATH, for the external debugger program. 
  67.  
  68. Q: When I run my programs under Windows, they crash, but not outside of
  69.    Windows.
  70. A: You may have used the "-fomit-frame-pointer" option to GCC.  This
  71.    tells gcc that it can use EBP as a general register.  However, the
  72.    segment used for the stack is protected against access outside of
  73.    calculated stack range, and EBP causes the stack selector to be used.
  74.    If you use this to access memory in the regular data area, you get
  75.    a protection fault.  This mechanism is present to prevent you from
  76.    using so much stack that you begin corrupting data.  Outside of
  77.    Windows, a different method is used to detect stack overrun, so you
  78.    don't see this fault.
  79.  
  80. Q: How do I create symbolic links?
  81. A: Copy bin/stub.exe to the name of the link you want.  In this example,
  82.    let's say the real program is dj1.exe and we want to make a link called
  83.    dj2.exe that really calls dj1.exe.  We'd copy stub.exe to dj2.exe.
  84.    Next, run stubedit to modify the new programs' stub info block to change
  85.    the name of the executable it runs.  In this case, we'd change it to
  86.    dj1.  When you run dj2 now, it tells go32 to use the image of dj1.
  87.      C:\> copy c:\djgpp\bin\stub.exe c:\usr\bin\dj2.exe
  88.      C:\> stubedit c:/usr/bin/dj2.exe runfile=dj1
  89.  
  90. Q: When I run "gcc e:\proj\prog.c" it says "undefined escape sequence \p"?
  91. A: Gcc is a *unix* compiler - you must use *unix* slashes (e:/proj/prog.c).
  92.    Environment variables (like GCCINC) may, however, use either, as they
  93.    are converted.
  94.  
  95. Q: I type "GCC PROG.C" and ld complains about PROG.C not being an object.
  96. Q: I type "gcc prog.cxx" to compile a C++ program, and ld complains.
  97. A: Gcc is *not* case insensitive like DOS is, and it uses the file's
  98.    extension to determine how to compile a file.  Valid extensions are:
  99.      .cc = C++ source (passed through cpp)
  100.      .c = C source that must be passed through cpp first
  101.      .i = raw C source (no cpp pass)
  102.      .S = assembler that must be passed through cpp first
  103.      .s = raw assembler source (no cpp pass)
  104.    any other file is passed to the linker
  105.  
  106. Q: I compile my program, but can't run the output file.
  107. A: DOS doesn't know how to run unix-style COFF files.  That's what the
  108.    extender is for.  To run an COFF file called myprog, type
  109.      "go32 myprog . . ."
  110.  
  111. Q: I compile my program, but when I run the .exe it hangs.
  112. A: Most likely, you did this: "gcc foo.c -o foo.exe".  This doesn't
  113.    create a real .EXE file.  That's like renaming your phone directory
  114.    file to an .EXE and expecting it to run.  You must use the COFF2EXE
  115.    program to convert the output of gcc to a real executable. 
  116.  
  117. Q: Gcc doesn't recognize // as a comment in my C programs.
  118. A: That's because // isn't a comment in C.  If you want to compile C++,
  119.    then write C++ programs.  Gcc is really two compilers in one, not
  120.    one compiler that compiles both C and C++.  That's why you get
  121.    cc1 and cc1plus.
  122.  
  123. Q: I'm reading in data files, but the data gets corrupted.
  124. A: The default file type is DOS text, even for read() and write().  You must
  125.    tell the system that a file is binary through the "b" flag in fopen(),
  126.    or O_BINARY in open() or setmode().
  127.  
  128. Q: I get "fatal signal 2" when I run gcc.
  129. A: When gcc reports a "signal", it really means that an error occurred
  130.    trying to run the given program.  The "signal" number is the DOS error
  131.    code, and 2 means "file not found".  Check the COMPILER_PATH environment
  132.    variable and make sure it points to the directory with cpp.exe,
  133.    cc1.exe, etc.
  134.  
  135. Q: The binaries I get with the distribution are .exe files, but gcc creates
  136.    COFF files.  I rename the COFF's to .EXE's, but they still don't work.
  137. A: To get an .EXE from an COFF, you must *prepend* either go32.exe
  138.    or stub.exe to the file.  A program called "coff2exe" is provided to
  139.    do this.  Just run "coff2exe myprog".
  140.  
  141. Q: What is stub.exe?
  142. A: Stub.exe simply calles go32.exe, and passes it information it needs to
  143.    run the COFF file attached to it.  Stub is much smaller than go32, so
  144.    less disk space is used.  Also, if you change go32, you don't have to
  145.    change stub, and all the stub-ized programs will use the new go32
  146.    automatically.
  147.  
  148. Q: I want to change cc1.  How do I do this?
  149. A: First, get the GNU sources.  These should be the "gccXXXsr.zip"
  150.    files found in the djgpp distribution.  You can also get the latest
  151.    versions from the FSF if you like.  They're usually available at
  152.    prep.ai.mit.edu in /pub/gnu, if not elsewhere.  djgpp includes a
  153.    copy of gzip (gzp124bn.zip) that can uncompress them. Use
  154.    djtarx to un-tar them, as djtarx knows how to handle unix file names
  155.    that aren't valid DOS file names.  Next, apply the "diffs" (if any)
  156.    over the GNU sources (making sure you have the right version of GNU
  157.    - see the versions file).  For most GNU utilities, you must run
  158.    "configure" to prepare the sources for a native go32 build before
  159.    building. For all other programs, just run make. Note that the makefiles
  160.    are tuned for gnu make, since it knows how to handle long command lines.
  161.    Specific instructions are documented in the diffs or in each program's
  162.    configure.bat.
  163.  
  164. Q: I don't have an 80387.  How do I compile floating point programs?
  165. A: Add "emu c:\djgpp\bin\emu387" to the GO32 environment variable
  166.    (see go32 section in readme).  This tells go32 to use the given file
  167.    as an 80387 emulator.  If you don't load this emulator, and you try
  168.    to run floating point without a 387, you will get an error.
  169.  
  170. Q: I installed an 80387 emulator in my AUTOEXEC, but it still doesn't
  171.    work.  Why?
  172. A: The CPU is running in *protected* mode, not real mode, and the information
  173.    needed to emulate the 80387 is different.  Not to mention that the
  174.    exceptions never get to the real-mode handler.  You must use the emu387
  175.    emulator, which is designed for go32.
  176.  
  177. Q: Can I run this on my 286?  It has protected mode also...
  178. A: True, but the 286 isn't a 32-bit processor.  A 386 really is required.
  179.  
  180. Q: Can I use gcc on my 512K machine?
  181. A: Yes, but the disk better have at least 4Mb of free space for paging.
  182.    Go32 will use all available extended memory (up to 128M) and up to
  183.    128M of disk space, for a grand total of 256M of virtual memory for
  184.    your application.  Try a malloc(50*1024*1024) some day.
  185.  
  186. Q: Why do my compiles are running VERY SLOW, even though I use a ramdisk
  187.    for swap and a disk cache?
  188. A: Gcc requires at least 1Mb of virtual memory to run, usually close to 1.5M.
  189.    If there isn't this much real memory available, it starts paging to disk.
  190.    It's good to leave about 1M of extended (not expanded) memory available
  191.    for go32 to run programs with.  When it needs to page a lot, you spend
  192.    most of your time paging and little time actually running.  Note that
  193.    if you are running with a VCPI server, like QEMM or 386MAX, then go32
  194.    will use *expanded* memory for it's physical memory needs, not
  195.    extended.
  196.  
  197. Q: How much memory is available when I use the system() call?
  198. A: Everything but what go32 is loaded with.  The program is completely
  199.    paged out to memory (including the page tables themselves) before
  200.    the second program is executed.  Currently, this is about 100K
  201.    less than was available before go32 was executed.
  202.  
  203. Q: Go32 complains that the CPU must be in V86 mode to run.
  204. A: When the CPU is in V86 mode, the V86 manager must provide VCPI
  205.    services for go32.  Since VCPI is an extension to EMS, disabling EMS
  206.    will disable VCPI, and prevent go32 from running.  For some EMS
  207.    managers, this means that you can't use the "noems" switch. 
  208.  
  209. Q: Why can't I keep QEMM in auto/off mode?
  210. A: When QEMM is in auto/off mode and there isn't anything in the system that
  211.    is using any of QEMM's features, the CPU remains in "real" mode.  Go32
  212.    knows this, and will try to use XMS to access the extended memory.
  213.    Unfortunately, XMS is a feature that causes QEMM to turn on, and go32
  214.    doesn't know this and when it tries to switch into protected mode,
  215.    QEMM traps it and gives a protection violation warning.  Since this
  216.    always requires a system reboot to fix, go32 checks to see if enabling
  217.    XMS caused the cpu to switch into v86 mode (meaning QEMM just turned
  218.    on) and gracefully exits.  All you have to do to work around this is
  219.    force QEMM to be on all the time so that go32 will know how to work
  220.    with it properly.
  221.  
  222. Q: How do globbing and response files work?
  223. A: A response file is a file that contains stuff that goes on the command
  224.    line, but is too big for DOS.  The name of the file is given as "@file"
  225.    to any COFF program, and go32 reads the file for command line
  226.    information.  It uses single and double quotes to group parameters, and
  227.    backslashes to escape quotes, spaces, tabs, newlines, and backslashes. 
  228.    Parameters containing wildcards are expanded if they can be, else they
  229.    are unmodified.  Surrounding a parameter in single quotes will prevent
  230.    wildcards from being expanded.  This is similar to unix.  Note that
  231.    backslashes are not special if they are not in front of a quote,
  232.    whitespace, or backslash. 
  233.  
  234. Q: What is GCC-RM?  How do I use it?
  235. A: GCC is merely a driver program which calls the CCP, CC1, AS, LD images.
  236.    The real-mode gcc is simply gcc itself compiled with Turbo-C instead of
  237.    Gcc.  This improves compile times on most systems, but isn't as
  238.    "clean" as the 32-bit compiled version, and also the 32-bit version
  239.    can be recompiled (FSF desires) without having to purchase a new
  240.    compiler.  Both versions should produce exactly the same output, but
  241.    if you have any problems (such as under Novell) use the 32 bit version.
  242.    You can either put GCC-RM in your path and issue GCC as your compile
  243.    command, or copy it to the bin directory (saving the 32 bit GCC.EXE first).
  244.    GCC-RM does not create 16 bit code, or allow the compiler to work on
  245.    16 bit only machines.
  246.  
  247. Q: Is GDB available for DJGPP?
  248. A: No, but if you'd like to work on porting it, let me know :-)
  249.  
  250. Q: Where is the "make" utility?
  251. A: mak369bn.zip contains the make utility.
  252.  
  253. Q: Why can't I get segment registers to work in go32 programs?
  254. A: Because segments work differently in protected mode.  For most cases, you
  255.    will not need to use segments.  The "small" model allows up to
  256.    2 Gb of data space before you run out, so there's no need
  257.    for far pointers anyway.
  258.