Go to the first, previous, next, last section, table of contents.

# What are the rules for shipping code built with g++ and libg++?

"Is it is possible to distribute programs for profit that are created with g++ and use the g++ libraries?"

I am not a lawyer, and this is not legal advice. In any case, I have little interest in telling people how to violate the spirit of the GNU licenses without violating the letter. This section tells you how to comply with the intention of the GNU licenses as best I understand them.

The FSF has no objection to your making money. Its only interest is that source code to their programs, and libraries, and to modified versions of their programs and libraries, is always available.

The short answer is that you do not need to release the source to your program, but you can't just ship a stripped executable either, unless you use only the subset of libg++ that includes the iostreams classes (see discussion below) or the new libstdc++ library (available in libg++ 2.6.2 and later).

Compiling your code with a GNU compiler does not affect its copyright; it is still yours. However, in order to ship code that links in a GNU library such as libg++ there are certain rules you must follow. The rules are described in the file COPYING.LIB that accompanies gcc distributions; it is also included in the libg++ distribution. See that file for the exact rules. The agreement is called the Library GNU Public License or LGPL. It is much "looser" than the GNU Public License, or GPL, that covers must GNU programs.

Here's the deal: let's say that you use some version of libg++, completely unchanged, in your software, and you want to ship only a binary form of your code. You can do this, but there are several special requirements. If you want to use libg++ but ship only object code for your code, you have to ship source for libg++ (or ensure somehow that your customer already has the source for the exact version you are using), and ship your application in linkable form. You cannot forbid your customer from reverse-engineering or extending your program by exploiting its linkable form.

Furthermore, if you modify libg++ itself, you must provide source for your modifications (making a derived class does not count as modifying the library -- that is "a work that uses the library").

For certain portions of libg++ that implement required parts of the C++ language (such as iostreams and other standard classes), the FSF has loosened the copyright requirement still more by adding the "special exception" clause, which reads as follows:

> As a special exception, if you link this library with files compiled with GCC to produce an executable, this does not cause the resulting executable to be covered by the GNU General Public License. This exception does not however invalidate any other reasons why the executable file might be covered by the GNU General Public License.

If your only use of libg++ uses code with this exception, you may ship stripped executables or license your executables under different conditions without fear of violating an FSF copyright. It is the intent of FSF and Cygnus that, as the other classes required by the ANSI/ISO draft standard are developed, these will also be placed under this "special exception" license. The code in the new libstdc++ library, intended to implement standard classes as defined by ANSI/ISO, is also licensed this way.

To avoid coming under the influence of the LGPL, you can link with ``-liostream'` rather than ``-lg++'` (for version 2.6.x and earlier), or ``-lstdc++'` now that it is available. In version 2.7.0 all the standard classes are in ``-lstdc++'`; you can do the link step with `c++` instead of `g++` to search only the ``-lstdc++'` library and avoid the LGPL'ed code in ``-lg++'`.

If you wish to discuss legal issues connected with GNU software on the net, please use ``gnu.misc.discuss'`, not the technical newsgroups.

Go to the first, previous, next, last section, table of contents.