home *** CD-ROM | disk | FTP | other *** search
/ Danny Amor's Online Library / Danny Amor's Online Library - Volume 1.iso / html / faqs / faq / g++-faq / plain next >
Encoding:
Text File  |  1995-07-25  |  47.4 KB  |  1,169 lines

  1. Subject: FAQ for g++ and libg++, plain text version [Revised 01 Nov 1994]
  2. Newsgroups: gnu.g++.help,comp.lang.c++,news.answers,comp.answers
  3. From: jbuck@synopsys.com (Joe Buck)
  4. Date: 2 Nov 1994 06:00:30 GMT
  5.  
  6. Archive-name: g++-FAQ/plain
  7. Last-modified: 01 Nov 1994
  8. Frequency: bimonthly
  9.  
  10. [ this is the plain text version, the parent is the texinfo version ]
  11.  
  12.  
  13. Preface
  14. *******
  15.  
  16.    This is a list of frequently asked questions (FAQ) for g++ users;
  17. thanks to all those who sent suggestions for improvements.  Thanks to
  18. Marcus Speh for doing the index.
  19.  
  20.    Many FAQ's, including this one, are available on the archive site
  21. rtfm.mit.edu, in the directory `pub/usenet/news.answers'.  This FAQ may
  22. be found in the subdirectory g++-FAQ.
  23.  
  24.    Some information in this FAQ was developed for earlier versions of
  25. the compiler and may now be obsolete.  Please send corrections.
  26.  
  27.    I'm looking for new questions (*with* answers), better answers, or
  28. both.  There should be more on templates, and the Standard Template
  29. Library, for example.  Maybe next time.  You can mail comments,
  30. suggestions, flames, etc. to jbuck@synopsys.com.  Please don't assume,
  31. though, that because my name is on this thing that I am the world
  32. expert on g++/C++ and you should mail all your tricky questions to me.
  33. I'd like to be helpful but I'm getting more of this than I can deal
  34. with lately.  Also please don't assume that I am an official spokesman
  35. for g++, FSF, or Cygnus; I'm not.
  36.  
  37.    This FAQ is intended to supplement, not replace, Marshall Cline's
  38. excellent FAQ for the C++ language and for the newsgroup comp.lang.c++.
  39. Especially if g++ is the first C++ compiler you've ever used, the
  40. question "How do I do <X> with g++?" is probably really "How do I do
  41. <X> in C++?".  You can obtain the C++ FAQ on rtfm.mit.edu as described
  42. above.
  43.  
  44.    The big news is that the long-awaited 2.6.0 release is now out.  I
  45. have not yet had time to thoroughly revise the FAQ to reflect this, so
  46. for now there is a separate "what's new in 2.6.0" section.  Some of the
  47. other information is now outdated.
  48.  
  49.  
  50. What's new in version 2.6.0 of gcc/g++
  51. **************************************
  52.  
  53.    The long-awaited version 2.6.0 of gcc/g++ (along with a matching
  54. version of libg++) have now been released.  This represents a great
  55. deal of work on the part of the g++ maintainers to fix outstanding bugs
  56. and move the compiler closer to the current ANSI/ISO standards
  57. committee's working paper, including supporting some of the new
  58. features that have been added to the language.  For example:
  59.  
  60.    * built-in boolean type 'bool', with constants 'true' and 'false'
  61.      (this will break code that uses these keywords as variable names).
  62.  
  63.    * overloaded operator for array new and delete (operator new [] and
  64.      delete []).
  65.  
  66.    * WP-conforming lifetime of temporaries (temporaries now live longer
  67.      than they used to).
  68.  
  69.    * explicit instantiation of templates (template class A<int>;),
  70.      along with an option (-fno-implicit-templates) to disable emission
  71.      of implicitly instantiated templates, obsoletes
  72.      -fexternal-templates.
  73.  
  74.    * static member constants (static const int foo = 4; within the
  75.      class declaration).
  76.  
  77.    * There is an *alpha* version of exception handling that currently
  78.      works *only* on Sparcs running SunOS 4.1.x.  Full exception
  79.      support will still take a while longer.
  80.  
  81.    * An undocumented feature: 2.6.0 parses the new cast expressions
  82.      containing the keywords `static_cast', `reinterpret_cast',
  83.      `const_cast', and `dynamic_cast'.  For the time being, the first
  84.      three are silently turned into normal casts (in my opinion, a
  85.      warning should be given that they aren't completely supported).
  86.      `dynamic_cast' will yield a "sorry, not yet implemented" message,
  87.      since it requires run-time type identification support to
  88.      implement.
  89.  
  90.    Also there have been many bug fixes, in nested types, access control,
  91. pointers to member functions, the parser, templates, overload
  92. resolution, etc, etc.  Finally, `.cpp' is now supported as a C++ file
  93. extension.
  94.  
  95.    Note that g++ 2.6.x won't compile libg++ 2.5.3 (due to a bug in
  96. libg++); you'll need libg++ 2.6, which is also now available.
  97.  
  98.    Despite what the `NEWS' file in the distribution says, the original
  99. Fresco distributed with X11R6 did not quite compile, because of use of
  100. "true" and "false" that conflicts with the new bool type.  This problem
  101. was fixed in public patch #5 to X11R6, so Fresco should now build fine
  102. with g++ 2.6 provided that you have installed this patch.
  103.  
  104.    2.6.0 fixes many bugs, but as with any "x.y.0" release there will be
  105. a few glitches.  You can expect a 2.6.1 shortly.  You can help
  106. contribute to the quality of the compiler by trying it out and
  107. submitting bug reports where you find them.  So far, 2.6.0 looks much
  108. better than early 2.5.x releases, though production users might want to
  109. wait for another minor release before switching.
  110.  
  111.  
  112. Obtaining Source Code
  113. *********************
  114.  
  115.  
  116. How do I get a copy of g++ for Unix?
  117. ====================================
  118.  
  119.    First, you may already have it if you have gcc for your platform;
  120. g++ and gcc are combined now (as of gcc version 2.0).
  121.  
  122.    You can get g++ from a friend who has a copy, by anonymous FTP or
  123. UUCP, or by ordering a tape or CD-ROM from the Free Software Foundation.
  124.  
  125.    The Free Software Foundation is a nonprofit organization that
  126. distributes software and manuals to raise funds for more GNU
  127. development.  Getting your copy from the FSF contributes directly to
  128. paying staff to develop GNU software.  CD-ROMs cost $400 if an
  129. organization is buying, or $100 if an individual is buying.  Tapes cost
  130. around $200 depending on media type.  I recommend asking for version 2,
  131. not version 1, of g++.
  132.  
  133.    For more information about ordering from the FSF, contact
  134. gnu@prep.ai.mit.edu, phone (617) 876-3296 or anonymous ftp file
  135. `/pub/gnu/GNUinfo/ORDERS' from prep.ai.mit.edu or one of the sites
  136. listed below.
  137.  
  138.    Here is a list of anonymous FTP archive sites for GNU software.
  139.  
  140.      ASIA: ftp.cs.titech.ac.jp, utsun.s.u-tokyo.ac.jp:/ftpsync/prep,
  141.      cair.kaist.ac.kr:/pub/gnu, ftp.nectec.or.th:/pub/mirrors/gnu
  142.      
  143.      AUSTRALIA: archie.oz.au:/gnu (archie.oz or archie.oz.au for ACSnet)
  144.      
  145.      AFRICA: ftp.sun.ac.za:/pub/gnu
  146.      
  147.      MIDDLE-EAST: ftp.technion.ac.il:/pub/unsupported/gnu
  148.      
  149.      EUROPE: irisa.irisa.fr:/pub/gnu, ftp.univ-lyon1.fr:pub/gnu,
  150.      ftp.mcc.ac.uk, unix.hensa.ac.uk:/pub/uunet/systems/gnu, ftp.denet.dk,
  151.      src.doc.ic.ac.uk:/gnu, ftp.eunet.ch, nic.switch.ch:/mirror/gnu,
  152.      ftp.informatik.rwth-aachen.de:/pub/gnu, ftp.informatik.tu-muenchen.de,
  153.      ftp.win.tue.nl:/pub/gnu, ftp.funet.fi:/pub/gnu, ftp.stacken.kth.se,
  154.      isy.liu.se, ftp.luth.se:/pub/unix/gnu, ftp.sunet.se:/pub/gnu,
  155.      archive.eu.net
  156.      
  157.      SOUTH AMERICA: ftp.unicamp.br:/pub/gnu
  158.      
  159.      WESTERN CANADA: ftp.cs.ubc.ca:/mirror2/gnu
  160.      
  161.      USA: wuarchive.wustl.edu:/systems/gnu, labrea.stanford.edu,
  162.      ftp.digex.net:/pub/gnu, ftp.kpc.com:/pub/mirror/gnu,
  163.      f.ms.uky.edu:/pub3/gnu, jaguar.utah.edu:/gnustuff,
  164.      ftp.hawaii.edu:/mirrors/gnu, vixen.cso.uiuc.edu:/gnu,
  165.      mrcnext.cso.uiuc.edu:/pub/gnu, ftp.cs.columbia.edu:/archives/gnu/prep,
  166.      col.hp.com:/mirrors/gnu, gatekeeper.dec.com:/pub/GNU,
  167.      ftp.uu.net:/systems/gnu
  168.  
  169.    The "official site" is prep.ai.mit.edu, but your transfer will
  170. probably go faster if you use one of the above machines.
  171.  
  172.    Most GNU utilities are compressed with "gzip", the GNU compression
  173. utility.  All GNU archive sites should have a copy of this program,
  174. which you will need to uncompress the distributions.
  175.  
  176.    UUNET customers can get GNU sources from UUNET via UUCP.  UUCP-only
  177. sites can get GNU sources by "anonymous UUCP" from site "osu-cis" at
  178. Ohio State University.  You pay for the long-distance call to OSU; the
  179. price isn't too bad on weekends at 9600 bps.  Send mail to
  180. uucp@cis.ohio-state.edu or osu-cis!uucp for more information.
  181.  
  182.    OSU lines are often busy.  If you're in the USA, and are willing to
  183. spend more money, you can get sources via UUCP from UUNET using their
  184. 900 number: 1-900-GOT-SRCS (900 numbers don't work internationally).
  185. You will be billed $0.50/minute by your phone company.
  186.  
  187.    Don't forget to retrieve libg++ as well!
  188.  
  189.  
  190. Getting gcc/g++ for the HP Precision Architecture
  191. =================================================
  192.  
  193.    If you use the HP Precision Architecture (HP-9000/7xx and
  194. HP-9000/8xx) and you want to use debugging, you'll need to use the GNU
  195. assembler, GAS (version 2.3 or later).  If you build from source, you
  196. must tell the configure program that you are using GAS or you won't get
  197. debugging support.  A non-standard debug format is used, since until
  198. recently HP considered their debug format a trade secret.  Thanks to
  199. the work of lots of good folks both inside and outside HP, the company
  200. has seen the error of its ways and has now released the required
  201. information.  The team at the University of Utah that did the gcc port
  202. now has code that understands the native HP format.
  203.  
  204.    Some enhancements for the HP that haven't been integrated back into
  205. the official GCC are available from the University of Utah, site
  206. jaguar.cs.utah.edu.  You can retrieve sources and prebuilt binaries for
  207. GCC (2.6.0.u2), GDB (4.13.u1), GAS (2.3.u1), and libg++ (2.6.u0); see
  208. the directory `/dist'.
  209.  
  210.    The libg++ version is actually the same as the FSF 2.6.  The Utah
  211. version of GDB can now understand both the GCC and HP C compiler debug
  212. formats, so it is no longer necessary to have two different GDB
  213. versions.
  214.  
  215.    I recommend that HP users use the Utah versions of the tools (see
  216. above).
  217.  
  218.    HP GNU users can also find useful stuff on the site geod.emr.ca in
  219. the `/pub/GNU-HP' directory.
  220.  
  221.  
  222. Getting gcc/g++ binaries for Solaris 2.x
  223. ========================================
  224.  
  225.    "Sun took the C compiler out of Solaris 2.x.  Am I stuck?"
  226.  
  227.    No; prep.ai.mit.edu and its mirror sites provide GCC binaries for
  228. Solaris.  As a rule, these binaries are not updated as often as the
  229. sources are, so if you want the very latest version of gcc/g++, you may
  230. need to grab and install binaries for an older version and use it to
  231. bootstrap the latest version from source.
  232.  
  233.    The latest gcc binaries on prep.ai.mit.edu and its mirror sites are
  234. for version 2.5.6 for Solaris on the Sparc, and version 2.4.5 for
  235. Solaris on Intel 386/486 machines.  There are also binaries for "gzip",
  236. the GNU compression utility, which you'll need for uncompressing the
  237. binary distribution.
  238.  
  239.    The ftp directory /pub/GNU on site camus.quintus.com contains various
  240. GNU and freeware programs for Solaris2.X running on the sparc. These are
  241. packaged to enable installation using the Solaris "pkgadd" utility.
  242. These include GNU emacs 19.19, gcc (and g++) 2.5.8, Perl 4.036, and
  243. others.
  244.  
  245.  
  246. How do I get a copy of g++ for (some other platform)?
  247. =====================================================
  248.  
  249.    The standard gcc/g++ distribution includes VMS support.  Since the
  250. FSF people don't use VMS, it's likely to be somewhat less solid than
  251. the Unix version.  Precompiled copies of g++ and libg++ in
  252. VMS-installable form are available by FTP from mango.rsmas.miami.edu.
  253. See also the site ftp.stacken.kth.se (in Sweden), directory
  254. /pub/GNU-VMS/contrib, which has gcc-2.5.8 and libg++-2.5.3.
  255.  
  256.    There are two different versions of gcc/g++ for MS-DOS: EMX and
  257. DJGPP.  EMX also works for OS/2 and is described later.  DJGPP is DJ
  258. Delorie's port.  It can be found on many FTP archive sites; its "home"
  259. is on oak.oakland.edu, directory `~ftp/pub/msdos/djgpp'.
  260.  
  261.    The latest version of DJGPP is 1.11.maint5.  This version runs under
  262. Windows 3.x.  It includes a port of gcc 2.5.7, plus support software.
  263.  
  264.    FSF sells floppies with DJGPP on them; see above for ordering
  265. software from the FSF.
  266.  
  267.    For information on Amiga ports of gcc/g++, retrieve the file
  268. `/pub/gnu/MicrosPorts/Amiga' from prep.ai.mit.edu, or write to Markus
  269. M. Wild <wild@nessie.cs.id.ethz.ch>, who I hope won't be too upset that
  270. I mentioned his name here.
  271.  
  272.    A port of gcc to the Atari ST can be found on the site
  273. "atari.archive.umich.edu", under `/atari/Gnustuff/Tos', along with many
  274. other GNU programs.  This version is usually the same as the latest FSF
  275. release.  See the "Software FAQ" for the Usenet group
  276. "comp.sys.atari.st" for more information.
  277.  
  278.    There are two different ports of gcc to OS/2, the so-called EMX port
  279. (which also runs on MS-DOS), and a port called "gcc/2".  The EMX port's
  280. C library attempts to provide a Unix-like environment; gcc/2 uses a
  281. rather buggy port of the BSD libc.  For more information ask around on
  282. "comp.os.os2.programmer.misc".
  283.  
  284.    The EMX port is available by FTP from
  285.  
  286.      ftp.uni-stuttgart.de(129.69.1.12) in /pub/systems/os2/emx-0.8h
  287.      src.doc.ic.ac.uk(146.169.2.1) in /pub/packages/os2/2_x/unix/gnu/emx08h
  288.      ftp.informatik.tu-muenchen.de(131.159.0.198) in
  289.              /pub/comp/os/os2/devtools/emx+gcc
  290.  
  291.    gcc/2, together with other GNUware for OS/2, can be obtained by FTP
  292. from
  293.  
  294.      ftp-os2.cdrom.com(192.153.46.2) in /pub/os2/2_x/unix/gnu
  295.      ftp-os2.nmsu.edu (128.123.35.151) in /pub/os2/2_x/unix/gnu
  296.      luga.latrobe.edu.au (131.172.2.2) in /pub/os2/2_x/unix/gnu
  297.  
  298.    The current maintainer of the gcc/2 port is Colin Jensen (Michael
  299. Johnson did the original port).  His address is cjensen@netcom.com.
  300.  
  301.    Eberhard Mattes did the EMX port.  His address is
  302. mattes@azu.informatik.uni-stuttgart.de.
  303.  
  304.    Because the legal policies of Apple threaten the long-term goals of
  305. FSF, as well as the concept of free software, no support will be lent to
  306. efforts to port GNU software to Macintosh or other Apple hardware.
  307.  
  308.  
  309. But I can only find g++-1.42!
  310. =============================
  311.  
  312.    "I keep hearing people talking about g++ 2.5.8 (or some other number
  313. starting with 2), but the latest version I can find is g++ 1.42.  Where
  314. is it?"
  315.  
  316.    As of gcc 2.0, C, C++, and Objective-C as well are all combined into
  317. a single distribution called gcc.  If you get gcc you already have g++.
  318. The standard installation procedure for any gcc version 2 compiler will
  319. install the C++ compiler as well.
  320.  
  321.    One could argue that we shouldn't even refer to "g++-2.x.y" but it's
  322. a convention.  It means "the C++ compiler included with gcc-2.x.y."
  323.  
  324.  
  325. What is the latest version of gcc, g++, and libg++?
  326. ===================================================
  327.  
  328.    The latest "2.x" version of gcc/g++ is 2.6.0, released July 14, 1994.
  329. The latest version of libg++ is 2.6.1, released October 24, 1994.
  330. Don't use 2.5.x, with x less than 5, for C++ code; there were some
  331. serious bugs that didn't have easy workarounds.  2.5.8 is the most
  332. solid 2.5.x release.
  333.  
  334.    For some non-Unix platforms, the latest port of gcc may be an earlier
  335. version (2.4.5, say).  You'll need to use a version of libg++ that has
  336. the same first two digits as the compiler version, e.g. use libg++ 2.4
  337. with gcc version 2.4.5.
  338.  
  339.    The latest "1.x" version of gcc is 1.42, and the latest "1.x"
  340. version of g++ is 1.42.0.  While gcc 1.42 is quite usable for C
  341. programs, I recommend against using g++ 1.x except in special
  342. circumstances.
  343.  
  344.  
  345. Installation Issues and Problems
  346. ********************************
  347.  
  348.  
  349. I can't build g++ 1.x.y with gcc-2.x.y!
  350. =======================================
  351.  
  352.    "I obtained gcc-2.x.y and g++ 1.x.y and I'm trying to build it, but
  353. I'm having major problems.  What's going on?"
  354.  
  355.    If you wish to build g++-1.42, you must obtain gcc-1.42 first.  The
  356. installation instructions for g++ version 1 leave a lot to be desired,
  357. unfortunately, and I would recommend that, unless you have a special
  358. reason for needing the 1.x compiler, that C++ users use the latest
  359. g++-2.x version, as it is the version that is being actively maintained.
  360.  
  361.    There is no template support in g++-1.x, and it is generally much
  362. further away from the ANSI draft standard than g++-2.x is.
  363.  
  364.  
  365. OK, I've obtained gcc; what else do I need?
  366. ===========================================
  367.  
  368.    First off, you'll want libg++ as you can do almost nothing without it
  369. (unless you replace it with some other class library).
  370.  
  371.    Second, depending on your platform, you may need "gas", the GNU
  372. assembler, or the GNU linker (see next question).
  373.  
  374.    Finally, while it is not required, you'll almost certainly want the
  375. GNU debugger, gdb.  The latest version is 4.13, released Aug. 14, 1994.
  376. Other debuggers (like dbx, for example) will normally not be able to
  377. understand at least some of the debug information produced by g++.
  378.  
  379.  
  380. Should I use the GNU linker, or should I use "collect"?
  381. =======================================================
  382.  
  383.    First off, for novices: special measures must be taken with C++ to
  384. arrange for the calling of constructors for global or static objects
  385. before the execution of your program, and for the calling of
  386. destructors at the end.  (Exception: System VR3 and System VR4 linkers
  387. support user-defined segments; g++ on these systems requires neither
  388. the GNU linker nor collect.  So if you have such a system, the answer
  389. is that you don't need either one).
  390.  
  391.    If you have experience with AT&T's "cfront", this function is
  392. performed there by programs named "patch" or "munch".  With GNU C++, it
  393. is performed either by the GNU linker or by a program known as
  394. "collect".  The collect program is part of the gcc-2.x distribution;
  395. you can obtain the GNU linker separately as part of the "binutils"
  396. package.  The latest version of binutils is 2.5.1, released October 22,
  397. 1994.
  398.  
  399.    (To be technical, it's "collect2"; there were originally several
  400. alternative versions of collect, and this is the one that survived).
  401.  
  402.    There are advantages and disadvantages to either choice.
  403.  
  404.    Advantages of the GNU linker:
  405.  
  406.    It's faster than using collect - collect basically runs the standard
  407. Unix linker on your program twice, inserting some extra code after the
  408. first pass to call the constructors.  This is a sizable time penalty
  409. for large programs.  The GNU linker does not require this extra pass.
  410.  
  411.    GNU ld reports undefined symbols using their true names, not the
  412. mangled names.
  413.  
  414.    If there are undefined symbols, GNU ld reports which object file(s)
  415. refer to the undefined symbol(s).
  416.  
  417.    As of binutils version 2.2, on systems that use the so-called "a.out"
  418. debug format (e.g. Suns running SunOS 4.x), the GNU linker compresses
  419. the debug symbol table considerably, which in at least some cases may
  420. make up, in disk space, for its inability to use shared libraries.
  421.  
  422.    Advantages of collect:
  423.  
  424.    If your native linker supports shared libraries, you can use shared
  425. libraries with collect.  The GNU linker does not (yet) support shared
  426. libraries.
  427.  
  428.    Note: using existing shared libraries (X and libc, for example) works
  429. very nicely; generating shared libraries from g++-compiled code is
  430. another matter, generally requiring OS-dependent tricks if it is
  431. possible at all.
  432.  
  433.    Ron Guilmette has written a set of patches for the g++ compiler that
  434. will permit people using g++ on SVr4 systems (including Solaris) to
  435. build ELF format shared libraries.  These patches ensure that any file
  436. scope static-storage objects within such libraries will be properly
  437. initialized when the libraries are first attached to your running
  438. process.  These patches are for version 2.5.8.  They *might* be
  439. incorporated into the standard 2.6 distribution, but this isn't certain
  440. yet.
  441.  
  442.    Contact Ron at <rfg@netcom.com> for further information and to get
  443. the patches.
  444.  
  445.    The GNU linker has not been ported to as many platforms as g++ has,
  446. so you may be forced to use collect.
  447.  
  448.    If you use collect, you don't need to get something extra and figure
  449. out how to install it; the standard gcc installation procedure will do
  450. it for you.
  451.  
  452.    In conclusion, I don't see a clear win for either alternative at this
  453. point.  Take your pick.
  454.  
  455.  
  456. Should I use the GNU assembler, or my vendor's assembler?
  457. =========================================================
  458.  
  459.    This depends on your platform and your decision about the GNU
  460. linker.  For most platforms, you'll need to use gas if you use the GNU
  461. linker.  For some platforms, you have no choice; check the gcc
  462. installation notes to see whether you must use gas.  But you can
  463. usually use the vendor's assembler if you don't use the GNU linker.
  464.  
  465.    The GNU assembler assembles faster than many native assemblers;
  466. however, on many platforms it cannot support the local debugging format.
  467.  
  468.    If you want to build shared libraries from gcc/g++ output and you
  469. are on a Sun, you must *not* use GNU as, as it cannot do
  470. position-independent code correctly yet.
  471.  
  472.    The gas distribution has recently been merged with the binutils
  473. distribution, so the GNU assembler and linker are now together in this
  474. package (as of binutils version 2.5.1).
  475.  
  476.  
  477. Should I use the GNU C library?
  478. ===============================
  479.  
  480.    At this point in time, no.  The GNU C library is still very young,
  481. and libg++ still conflicts with it in some places.  Use your native C
  482. library unless you know a lot about the gory details of libg++ and
  483. gnu-libc.  This will probably change in the future.
  484.  
  485.  
  486. Global constructors aren't being called
  487. =======================================
  488.  
  489.    "I've installed gcc and it almost works, but constructors and
  490. destructors for global objects and objects at file scope aren't being
  491. called.  What did I do wrong?"
  492.  
  493.    It appears that you are running on a platform that requires you to
  494. install either "collect2" or the GNU linker, and you have done neither.
  495. For more information, see the section discussing the GNU linker (*Note
  496. use GNU linker?::).
  497.  
  498.    On Solaris 2.x, you shouldn't need a collect program and GNU ld
  499. doesn't run.  If your global constructors aren't being called, you may
  500. need to install a patch, available from Sun, to fix your linker.  The
  501. number of the "jumbo patch" that applies is 101409-03.  Thanks to
  502. Russell Street (r.street@auckland.ac.nz) for this info.
  503.  
  504.    It appears that on IRIX, the collect2 program is not being installed
  505. by default during the installation process, though it is required; you
  506. can install it manually by executing
  507.  
  508.      make install-collect2
  509.  
  510.    from the gcc source directory after installing the compiler.
  511.  
  512.  
  513. Strange assembler errors when linking C++ programs
  514. ==================================================
  515.  
  516.    "I've installed gcc and it seemed to go OK, but when I attempt to
  517. link any C++ program, I'm getting strange errors from the assembler!
  518. How can that be?"
  519.  
  520.    The messages in question might look something like
  521.  
  522.      as: "/usr/tmp/cca14605.s", line 8: error: statement syntax
  523.      as: "/usr/tmp/cca14605.s", line 14: error: statement syntax
  524.  
  525.    (on a Sun, different on other platforms).  The important thing is
  526. that the errors come out at the link step, *not* when a C++ file is
  527. being compiled.
  528.  
  529.    Here's what's going on: the collect2 program uses the Unix "nm"
  530. program to obtain a list of symbols for the global constructors and
  531. destructors, and it builds a little assembly language module that will
  532. permit them all to be called.  If you're seeing this symptom, you have
  533. an old version of GNU nm somewhere on your path.  This old version
  534. prints out symbol names in a format that the collect2 program does not
  535. expect, so bad assembly code is generated.
  536.  
  537.    The solution is either to remove the old version of GNU nm from your
  538. path (and that of everyone else who uses g++), or to install a newer
  539. version (it is part of the GNU "binutils" package).  Recent versions of
  540. GNU nm do not have this problem.
  541.  
  542.  
  543. Problems building libg++ on 386/486
  544. ===================================
  545.  
  546.    Attempts to install libg++ on 386 or 486 systems running ports of
  547. SVR4 have problems because of bugs in debugging support on that
  548. platform.  Briefly, debugging does not currently work right yet for
  549. C++.  You should be able to build the library successfully by deleting
  550. the `-g' flag from the Makefiles (this should no longer be necessary
  551. with gcc 2.4.x although debugging still doesn't work).
  552.  
  553.    See the section entitled "Debugging on SVR4 systems."
  554.  
  555.  
  556. Other problems building libg++
  557. ==============================
  558.  
  559.    "I am having trouble building libg++.  Help!"
  560.  
  561.    On some platforms (for example, Ultrix), you may see errors
  562. complaining about being unable to open dummy.o.  On other platforms
  563. (for example, SunOS), you may see problems having to do with the type
  564. of size_t.  The fix for these problems is to make libg++ by saying
  565. "make CC=gcc".  According to Per Bothner, it should no longer be
  566. necessary to specify "CC=gcc" for libg++-2.3.1 or later.
  567.  
  568.    "I built and installed libg++, but g++ can't find it.  Help!"
  569.  
  570.    The string given to `configure' that identifies your system must be
  571. the same when you install libg++ as it was when you installed gcc.
  572. Also, if you used the `--prefix' option to install gcc somewhere other
  573. than `/usr/local', you must use the same value for `--prefix' when
  574. installing libg++, or else g++ will not be able to find libg++.
  575.  
  576.  
  577. But I'm *still* having problems with `size_t'!
  578. ==============================================
  579.  
  580.    "I did all that, and I'm *still* having problems with disagreeing
  581. definitions of size_t, SIZE_TYPE, and the type of functions like
  582. `strlen'."
  583.  
  584.    The problem may be that you have an old version of `_G_config.h'
  585. lying around.  As of libg++ version 2.4, `_G_config.h', since it is
  586. platform-specific, is inserted into a different directory; most include
  587. files are in `$prefix/lib/g++-include', but this file now lives in
  588. `$prefix/$arch/include'.  If, after upgrading your libg++, you find that
  589. there is an old copy of `_G_config.h' left around, remove it, otherwise
  590. g++ will find the old one first.
  591.  
  592.  
  593. Do I need to rebuild libg++ to go with my new g++?
  594. ==================================================
  595.  
  596.    "After I upgraded g++ to the latest version, I'm seeing undefined
  597. symbols."
  598.  
  599.    or
  600.  
  601.    "If I upgrade to a new version of g++, do I need to reinstall
  602. libg++?"
  603.  
  604.    As a rule, the first two digits of your g++ and libg++ should be the
  605. same.  Normally when you do an upgrade in the "minor version number"
  606. (2.5.7 to 2.5.8, say) there isn't a need to rebuild libg++, but there
  607. have been a couple of exceptions in the past.
  608.  
  609.  
  610. User Problems
  611. *************
  612.  
  613.  
  614. gcc 2.5.x broke my code!  Changes in function overloading
  615. =========================================================
  616.  
  617.    "I have a program that worked just fine with older g++ versions, but
  618. as of version 2.5.x it doesn't work anymore.  Help!"
  619.  
  620.    While it's always possible that a new bug has been introduced into
  621. the compiler, it's also possible that you have been relying on bugs in
  622. older versions of g++.  For example, version 2.5.0 was the first
  623. version of g++ to correctly implement the "hiding rule."  That is, if
  624. you have an overloaded function in a base class, and in a derived class
  625. you redefine one of the names, the other names are effectively "hidden".
  626. *All* the names from the baseclass need to be redefined in the derived
  627. class.  See section 13.1 of the ARM: "A function member of a derived
  628. class is *not* in the same scope as a function member of the same name
  629. in a base class".
  630.  
  631.    Here's an example that is handled incorrectly by g++ versions before
  632. 2.5.0 and correctly by newer versions:
  633.  
  634.      class Base {
  635.      public:
  636.          void foo(int);
  637.      };
  638.      
  639.      class Derived : public Base {
  640.      public:
  641.          void foo(double);  // *note that Base::foo(int) is hidden*
  642.      };
  643.      
  644.      main() {
  645.          Derived d;
  646.          d.foo(2); // *Derived::foo(double), not Base::foo(int), is called*
  647.      }
  648.  
  649.  
  650. Where can I find a demangler?
  651. =============================
  652.  
  653.    A g++-compatible demangler named `c++filt' can be found in the
  654. `binutils' distribution.  This distribution (which also contains the
  655. GNU linker) can be found at any GNU archive site.
  656.  
  657.  
  658. Where can I find a version of etags for C++?
  659. ============================================
  660.  
  661.    The libg++ distribution contains a version of etags that works for
  662. C++ code.  Look in `libg++/utils'.  It's not built by default when you
  663. install libg++, but you can cd to that directory and type
  664.  
  665.      make etags
  666.  
  667.    after you've installed libg++.
  668.  
  669.  
  670. Linker reports undefined symbols for static data members
  671. ========================================================
  672.  
  673.    "g++ reports undefined symbols for all my static data members when I
  674. link, even though the program works correctly for compiler XYZ.  What's
  675. going on?"
  676.  
  677.    The problem is almost certainly that you don't give definitions for
  678. your static data members.  If you have
  679.  
  680.      class Foo {
  681.          ...
  682.          void method();
  683.          static int bar;
  684.      };
  685.  
  686.    you have only declared that there is an int named Foo::bar and a
  687. member function named Foo::method that is defined somewhere.  You still
  688. need to defined BOTH method() and bar in some source file.  According
  689. to the draft ANSI standard, you must supply an initializer, such as
  690.  
  691.      int Foo::bar = 0;
  692.  
  693. in one (and only one) source file.
  694.  
  695.  
  696. g++ won't accept the placement new syntax.
  697. ==========================================
  698.  
  699.    "I have a program that uses the "placement syntax" of operator new,
  700. e.g.
  701.  
  702.         new (somewhere) T;
  703.  
  704. and g++ won't accept it."
  705.  
  706.    You must have a very old version of g++; everything since 2.3.1
  707. accepts placement new correctly.  The only remaining problems were with
  708. declarators for pointers to functions:
  709.  
  710.      new (void (*)(int));  // confuses gcc 2.3.2, some versions dump core (2.5.8)
  711.      new (a) (void (*)(int)); // ditto
  712.  
  713.    Even these work correctly with 2.6.0.  For older versions, these can
  714. be worked around with a typedef:
  715.  
  716.      typedef void (*fun)(int);
  717.      new fun;
  718.      new (a) fun;
  719.  
  720.  
  721. Overloaded increment (`++') and decrement (`--') operators
  722. ==========================================================
  723.  
  724.    "g++ doesn't seem to distinguish the prefix and postfix forms of
  725. `operator++'.  What gives?"
  726.  
  727.    This is a relatively new feature in the C++ language.  The solution
  728. is to upgrade your compiler; distinguishing the prefix and postfix cases
  729. of `operator++' and `operator--' was first implemented in g++ version
  730. 2.4.1.
  731.  
  732.    For backward compatibility, if a class declares a prefix version of
  733. `operator++' (or `operator--') but no postfix version, and code
  734. attempts to use `++' (or `--') as a postfix operator, g++ will use the
  735. prefix version (unless the `-pedantic' flag is set).  This feature is
  736. to avoid breaking old code.
  737.  
  738.  
  739. I think I have found a bug in g++.
  740. ==================================
  741.  
  742.    "I think I have found a bug in g++, but I'm not sure.  How do I know,
  743. and who should I tell?"
  744.  
  745.    First, see the excellent section on bugs and bug reports in the gcc
  746. manual (which is included in the gcc distribution).  As a short summary
  747. of that section: if the compiler gets a fatal signal, for any input,
  748. it's a bug (newer versions of g++ will ask you to send in a bug report
  749. when they detect an error in themselves).  Same thing for producing
  750. invalid assembly code.
  751.  
  752.    When you report a bug, make sure to describe your platform (the type
  753. of computer, and the version of the operating system it is running) and
  754. the version of the compiler that you are running.  Also provide enough
  755. code so that the g++ maintainers can duplicate your bug.
  756.  
  757.    I will add some extra notes that are C++-specific, since the notes
  758. from the gcc documentation are generally C-specific.
  759.  
  760.    First, mail your bug report to "bug-g++@prep.ai.mit.edu".  You may
  761. also post to gnu.g++.bug, but it's better to use mail, particularly if
  762. you have any doubt as to whether your news software generates correct
  763. reply addresses.  Don't mail C++ bugs to bug-gcc@prep.ai.mit.edu.
  764.  
  765.    If your bug involves libg++ rather than the compiler, mail to
  766. bug-lib-g++@prep.ai.mit.edu.  If you're not sure, choose one, and if you
  767. guessed wrong, the maintainers will forward it to the other list.
  768.  
  769.    Second, if your program does one thing, and you think it should do
  770. something else, it is best to consult a good reference if in doubt.  The
  771. standard reference is "The Annotated C++ Reference Manual", by Ellis and
  772. Stroustrup (copyright 1990, ISBN #0-201-51459-1).  This is what they're
  773. talking about on the net when they refer to "the ARM".
  774.  
  775.    The reference manual, without annotations, also appears in
  776. Stroustrup's "The C++ Programming Language, Second Edition" (copyright
  777. 1991, ISBN #0-201-53992-6).  Both books are published by Addison-Wesley.
  778.  
  779.    The ANSI/ISO C++ standards committee have adopted some changes to the
  780. C++ language since the publication of the original ARM, and newer
  781. versions of g++ (2.5.x and later) support some of these changes, notably
  782. the mutable keyword (added in 2.5.0) and the bool type (added in 2.6.0).
  783. You can obtain an addendum to the ARM explaining these changes by FTP
  784. from ftp.std.com in `/AW/stroustrup2e/iso.ps'.
  785.  
  786.    Note that the behavior of (any version of) AT&T's "cfront" compiler
  787. is NOT the standard for the language.
  788.  
  789.  
  790. Porting programs from other compilers to g++
  791. ============================================
  792.  
  793.    "I have a program that runs on <some other C++ compiler>, and I want
  794. to get it running under g++.  Is there anything I should watch out for?"
  795.  
  796.    First, see the questions on placement new syntax and static data
  797. members.
  798.  
  799.    Secondly, if the porting problem relates to the resolution of
  800. overloaded operators or functions, you might try the
  801. `-fansi-overloading' switch in g++ 2.5.0 or later.  This switch enables
  802. new code that attempts to match the ARM specification of overloaded
  803. argument resolution better.
  804.  
  805.    There are two other reasons why a program that worked under one
  806. compiler might fail under another: your program may depend on the order
  807. of evaluation of side effects in an expression, or it may depend on the
  808. lifetime of a temporary (you may be assuming that a temporary object
  809. "lives" longer than the standard guarantees).  As an example of the
  810. first:
  811.  
  812.      void func(int,int);
  813.      
  814.      int i = 3;
  815.      func(i++,i++);
  816.  
  817.    Novice programmers think that the increments will be evaluated in
  818. strict left-to-right order.  Neither C nor C++ guarantees this; the
  819. second increment might happen first, for example.  func might get 3,4,
  820. or it might get 4,3.
  821.  
  822.    The second problem often happens with classes like the libg++ String
  823. class.  Let's say I have
  824.  
  825.      String func1();
  826.      void func2(const char*);
  827.  
  828.    and I say
  829.  
  830.      func2(func1());
  831.  
  832.    because I know that class String has an "operator const char*".  So
  833. what really happens is
  834.  
  835.      func2(func1().convert());
  836.  
  837.    where I'm pretending I have a convert() method that is the same as
  838. the cast.  This is unsafe, because the temporary String object may be
  839. deleted after its last use (the call to the conversion function),
  840. leaving the pointer pointing to garbage, so by the time func2 is
  841. called, it gets an invalid argument.
  842.  
  843.    Both the cfront and the g++ behaviors are legal according to the ARM,
  844. but the powers that be have decided that compiler writers were given
  845. too much freedom here.  The ANSI C++ committee has now come to a
  846. resolution of the lifetime of temporaries problem: they specify that
  847. temporaries should be deleted at end-of-statement (and at a couple of
  848. other points).  This means that g++ now deletes temporaries too early,
  849. and cfront deletes temporaries too late.
  850.  
  851.    For now, the safe way to write such code is to give the temporary a
  852. name, which forces it to live until the end of the scope of the name.
  853. For example:
  854.  
  855.      String& tmp = func1();
  856.      func2(tmp);
  857.  
  858.    *UPDATE:* as of version 2.6.0, g++ deletes temporaries when the ANSI
  859. working paper says it should; the previous text refers to all earlier
  860. g++ versions.
  861.  
  862.    Finally, like all compilers (but especially C++ compilers, it seems),
  863. g++ has bugs, and you may have tweaked one.  If so, please file a bug
  864. report (after checking the above issues).
  865.  
  866.  
  867. Why does g++ mangle names differently from other C++ compilers?
  868. ===============================================================
  869.  
  870.    See the answer to the next question.
  871.  
  872.  
  873. Why can't g++ code link with code from other C++ compilers?
  874. ===========================================================
  875.  
  876.    "Why can't I link g++-compiled programs against libraries compiled by
  877. some other C++ compiler?"
  878.  
  879.    Some people think that, if only the FSF and Cygnus Support folks
  880. would stop being stubborn and mangle names the same way that, say,
  881. cfront does, then any g++-compiled program would link successfully
  882. against any cfront-compiled library and vice versa.  Name mangling is
  883. the least of the problems.  Compilers differ as to how objects are laid
  884. out, how multiple inheritance is implemented, how virtual function
  885. calls are handled, and so on, so if the name mangling were made the
  886. same, your programs would link against libraries provided from other
  887. compilers but then crash when run.  For this reason, the ARM
  888. *encourages* compiler writers to make their name mangling different
  889. from that of other compilers for the same platform.  Incompatible
  890. libraries are then detected at link time, rather than at run time.
  891.  
  892.  
  893. What documentation exists for g++ 2.x?
  894. ======================================
  895.  
  896.    Relatively little.  While the gcc manual that comes with the
  897. distribution has some coverage of the C++ part of the compiler, it
  898. focuses mainly on the C compiler (though the information on the "back
  899. end" pertains to C++ as well).  Still, there is useful information on
  900. the command line options and the #pragma interface and #pragma
  901. implementation directives in the manual.  There is a Unix-style manual
  902. entry, "g++.1", in the gcc-2.x distribution; the information here is a
  903. subset of what is in the manual.
  904.  
  905.    You can buy a nicely printed and bound copy of this manual from the
  906. FSF; see above for ordering information.
  907.  
  908.    Postscript versions of GNU documentation in U.S. letter format are
  909. availably by anonymous FTP to primus.com in /pub/gnu-ps.  The same, in
  910. A4 format, are on liasun3.epfl.ch in /pub/gnu/ps-doc.
  911.  
  912.    A draft of a document describing the g++ internals appears in the gcc
  913. distribution (called g++int.texi); it is still incomplete.
  914.  
  915.  
  916. What are the differences between g++ and the ARM specification of C++?
  917. ======================================================================
  918.  
  919.    The chief thing missing from g++ that is in the ARM is exceptions.
  920. There are bits and pieces of exception code present, but it is not
  921. presently usable.
  922.  
  923.    The template implementation is still new.  The implementation in
  924. 2.5.x represents a considerable improvement over that of previous
  925. releases, but it has a long way to go.  This continues to improve from
  926. release to release.
  927.  
  928.    g++ does not implement a separate pass to instantiate template
  929. functions and classes at this point; for this reason, it will not work,
  930. for the most part, to declare your template functions in one file and
  931. define them in another.  The compiler will need to see the entire
  932. definition of the function, and will generate a static copy of the
  933. function in each file in which it is used.  For 2.5.0, however, a new
  934. switch `-fexternal-templates' was added; this makes it possible to have
  935. only one globally visible copy of a given template expansion in your
  936. executable.  See the gcc manual for details.
  937.  
  938.    As of version 2.5.8, there are still a few limitations in the
  939. template implementation besides the above (thanks to Jason Merrill for
  940. this info):
  941.  
  942.   1. Static data member templates are not supported.
  943.  
  944.           template <class T> struct A {
  945.             static T t;
  946.           };
  947.           
  948.           template <class T> T A<T>::t = 0; // gets bogus error
  949.           int A<int>::t = 0;                // OK
  950.  
  951.   2. Template member names are not available when defining member
  952.      function templates.
  953.  
  954.           template <class T> struct A {
  955.             typedef T foo;
  956.             void f (foo);
  957.             void g (foo arg) { ... }; // this works
  958.           };
  959.           
  960.           template <class T> void A<T>::f (foo) { } // gets bogus error
  961.  
  962.   3. Templates are instantiated using the parser.  This results in two
  963.      problems:
  964.  
  965.      a) Class templates are instantiated in some situations where such
  966.      instantiation should not occur.
  967.  
  968.           template <class T> class A { };
  969.           A<int> *aip = 0; // should not instantiate A<int> (but does)
  970.  
  971.      b) Function templates cannot be inlined at the site of their
  972.      instantiation.
  973.  
  974.           template <class T> inline T min (T a, T b) { return a < b ? a : b; }
  975.           
  976.           void f () {
  977.             int i = min (1, 0);           // not inlined
  978.           }
  979.           
  980.           void g () {
  981.             int j = min (1, 0);           // inlined
  982.           }
  983.  
  984.      A workaround that will be available in 2.6.1 is to specify
  985.  
  986.           extern template int min (int, int);
  987.  
  988.      before `f()'; this will force it to be instantiated (though not
  989.      emitted). `extern template' is broken in 2.6.0, though, as people
  990.      trying to use iomanips have noticed.
  991.  
  992.   4. Member function templates are always instantiated when their
  993.      containing class is.  This is wrong.
  994.  
  995.    Some features that the ANSI/ISO standardization committee has voted
  996. in that don't appear in the ARM are supported, notably the `mutable'
  997. keyword, in version 2.5.x.
  998.  
  999.    As with any beta-test compiler, there are bugs.  You can help improve
  1000. the compiler by submitting detailed bug reports.
  1001.  
  1002.    One of the weakest areas of g++ other than templates is the
  1003. resolution of overloaded functions and operators in complex cases.  The
  1004. usual symptom is that in a case where the ARM says that it is ambiguous
  1005. which function should be chosen, g++ chooses one (often the first one
  1006. declared).  This is usually not a problem when porting C++ code from
  1007. other compilers to g++, but shows up as errors when code developed under
  1008. g++ is ported to other compilers.
  1009.  
  1010.    As of 2.5.0, the overloading code has been rewritten.  For now, you
  1011. must specify the option `-fansi-overloading' to get the new code, since
  1012. there were some important users actually depending on g++'s incorrect
  1013. resolution of ambiguities.  This switch should disappear in the future.
  1014. If a program that compiled under previous g++ versions now reports that
  1015. a use of an overloaded function is ambiguous, it is likely that the old
  1016. g++ was letting you write buggy code and the new one is detecting the
  1017. problem.  If in doubt, consult the ARM.
  1018.  
  1019.    [A full bug list would be very long indeed, so I won't put one here.
  1020. I may add a list of frequently-reported bugs and "non-bugs" like the
  1021. static class members issue mentioned above].
  1022.  
  1023.  
  1024. Will g++ compile InterViews?  The NIH class library?
  1025. ====================================================
  1026.  
  1027.    The NIH class library uses a non-portable, compiler-dependent hack
  1028. to initialize itself, which makes life difficult for g++ users.  It
  1029. will not work without modification, and I don't know what modifications
  1030. are required or whether anyone has done them successfully.
  1031.  
  1032.    In short, it's not going to happen any time soon (previous FAQs
  1033. referred to patches that a new NIHCL release would hopefully contain,
  1034. but this hasn't happened).
  1035.  
  1036.    [ From Steinar Bang <steinarb@idt.unit.no>]
  1037.  
  1038.    InterViews 3.1 compiles and runs with gcc-2.3.3 and libg++-2.3,
  1039. except that the "doc" application immediately dumps core when you try
  1040. to run it.  There is also a small glitch with idraw.
  1041.  
  1042.    There is a patch for InterViews 3.1 from Johan Garpendahl
  1043. <garp@isy.liu.se> available for FTP from site "ugle.unit.no".  It is in
  1044. the file
  1045.  
  1046.    `/pub/X11/contrib/InterViews/g++/3.1-beta3-patch'.
  1047.  
  1048.    This fixes two things: the Doc coredump, and the pattern menu of
  1049. idraw.  Read the instructions at the start of the file.
  1050.  
  1051.    I think that as of version 2.5.6, the standard g++ will compile the
  1052. standard 3.1 InterViews completely successfully.  I'd appreciate a
  1053. confirmation.
  1054.  
  1055.  
  1056. Debugging on SVR4 systems
  1057. =========================
  1058.  
  1059.    "When I use the `-g' flag on C++ code on a System V Release 4 system,
  1060. I get lots of undefined symbols at link time.  Why?  Help!"
  1061.  
  1062.    Most systems based on System V Release 4 (except Solaris) encode
  1063. symbolic debugging information in a format known as `DWARF'.
  1064.  
  1065.    Although the GNU C compiler already knows how to write out symbolic
  1066. debugging information in the DWARF format, the GNU C++ compiler does
  1067. not yet have this feature, nor is it likely to in the immediate future.
  1068.  
  1069.    Ron Guilmette has done a great deal of work to try to get the GNU
  1070. C++ com- piler to produce DWARF format symbolic debugging information
  1071. (for C++ code) but he gave up on the project because of a lack of
  1072. funding and/or interest from the g++ user community.  If you have a
  1073. strong desire to see this project completed, contact Ron at
  1074. <rfg@netcom.com>.
  1075.  
  1076.  
  1077. X11 conflicts with libg++ in definition of String
  1078. =================================================
  1079.  
  1080.    "X11 and Motif define String, and this conflicts with the String
  1081. class in libg++.  How can I use both together?"
  1082.  
  1083.    One possible method is the following:
  1084.  
  1085.      #define String XString
  1086.      #include <X11/Intrinsic.h>
  1087.      /* include other X11 and Motif headers */
  1088.      #undef String
  1089.  
  1090.    and remember to use the correct `String' or `XString' when you
  1091. declare things later.
  1092.  
  1093.  
  1094. What are the rules for shipping code built with g++ and libg++?
  1095. ***************************************************************
  1096.  
  1097.    "Is it is possible to distribute programs for profit that are created
  1098. with g++ and use the g++ libraries?"
  1099.  
  1100.    I am not a lawyer, and this is not legal advice.  In any case, I have
  1101. little interest in telling people how to violate the spirit of the GNU
  1102. licenses without violating the letter.  This section tells you how to
  1103. comply with the intention of the GNU licenses as best I understand them.
  1104.  
  1105.    The FSF has no objection to your making money.  Its only interest is
  1106. that source code to their programs, and libraries, and to modified
  1107. versions of their programs and libraries, is always available.
  1108.  
  1109.    The short answer is that you do not need to release the source to
  1110. your program, but you can't just ship a stripped executable either,
  1111. unless you use only the subset of libg++ that includes the iostreams
  1112. classes (see discussion below).
  1113.  
  1114.    Compiling your code with a GNU compiler does not affect its
  1115. copyright; it is still yours.  However, in order to ship code that
  1116. links in a GNU library such as libg++ there are certain rules you must
  1117. follow.  The rules are described in the file COPYING.LIB that
  1118. accompanies gcc distributions; it is also included in the libg++
  1119. distribution.  See that file for the exact rules.  The agreement is
  1120. called the Library GNU Public License or LGPL.  It is much "looser"
  1121. than the GNU Public License, or GPL, that covers must GNU programs.
  1122.  
  1123.    Here's the deal: let's say that you use some version of libg++,
  1124. completely unchanged, in your software, and you want to ship only a
  1125. binary form of your code.  You can do this, but there are several
  1126. special requirements.  If you want to use libg++ but ship only object
  1127. code for your code, you have to ship source for libg++ (or ensure
  1128. somehow that your customer already has the source for the exact version
  1129. you are using), and ship your application in linkable form.  You cannot
  1130. forbid your customer from reverse-engineering or extending your program
  1131. by exploiting its linkable form.
  1132.  
  1133.    Furthermore, if you modify libg++ itself, you must provide source
  1134. for your modifications (making a derived class does not count as
  1135. modifying the library - that is "a work that uses the library").
  1136.  
  1137.    For certain portions of libg++ that implement required parts of the
  1138. C++ language (such as iostreams), the FSF has loosened the copyright
  1139. requirement still more by adding the "special exception" clause, which
  1140. reads as follows:
  1141.  
  1142.      As a special exception, if you link this library with files
  1143.      compiled with GCC to produce an executable, this does not cause
  1144.      the resulting executable to be covered by the GNU General Public
  1145.      License.  This exception does not however invalidate any other
  1146.      reasons why the executable file might be covered by the GNU
  1147.      General Public License.
  1148.  
  1149.    If your only use of libg++ uses code with this exception, you may
  1150. ship stripped executables or license your executables under different
  1151. conditions without fear of violating an FSF copyright.  It is the intent
  1152. of FSF and Cygnus that, as the other classes required by the ANSI/ISO
  1153. draft standard are developed, these will also be placed under this
  1154. "special exception" license.
  1155.  
  1156.    To avoid coming under the influence of the LGPL, you can link with
  1157. `-liostream' rather than `-lg++'.
  1158.  
  1159.  
  1160. Concept Index
  1161. *************
  1162.  
  1163. -- 
  1164. -- Joe Buck     <jbuck@synopsys.com>    (not speaking for Synopsys, Inc)
  1165. "We act as though comfort and luxury were the chief requirements of life, when
  1166.  all that we need to make us happy is something to be enthusiastic about."
  1167.             - Albert Einstein
  1168.  
  1169.