Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: Q about distribiting software made with GCC

  1. #1
    Join Date
    Aug 2007
    Location
    Novocastria, Australia
    Beans
    751
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Q about distribiting software made with GCC

    I'm taking a course at Uni where we are leaning C++, and we are using the GCC for our labs and for assignments. The lecturer said something strange about the GCC though. I'm just wanting to know if what he said is right or not before I question him about it.

    He said that because the GCC is released under the GPLv2, we would only be able to distribute code created with it under the GPL as well (i.e. it can't be used commercially, at least in the traditional sense). Is this right? I would have though you could do anything with the code you created. The only thing I can think of is if maybe using include pre compiler directives could include GPLed code.

    Any thoughts on this?

  2. #2
    Join Date
    Apr 2005
    Location
    Finland
    Beans
    272

    Re: Q about distribiting software made with GCC

    Your lecturer is totally wrong. First of all, GCC is also licensed under the Lesser General Public License (http://en.wikipedia.org/wiki/GNU_Les...Public_License). And even if it wasn't, the license wouldn't apply to binaries created with the software, as long as no parts of GCC were distributed with said binaries.
    Last edited by scourge; August 2nd, 2008 at 09:36 AM.

  3. #3
    Join Date
    May 2008
    Beans
    Hidden!

    Re: Q about distribiting software made with GCC

    That would only be true if you statically link to a library that is licensed under the GPL in that case your program must also be released as GPL.

    However if you just use GCC to compile a program that doesn't statically link to any GPL code you are free to license your software as you wish.

    If what your lecturer is saying were true, Apple and Redhat and other companies would be in trouble right away.

    If you want to get away from compiling with a FSF compiler at all, you can use pcc, but it only compiles C code.

  4. #4
    Join Date
    Aug 2007
    Location
    Novocastria, Australia
    Beans
    751
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: Q about distribiting software made with GCC

    Yeah, it's that static linking that I'm worried about. For example, I use lots of:

    #include <istream>

    and that kind of thing pretty often. So are these considered "modules" or part of the compiler?

  5. #5
    Join Date
    May 2008
    Beans
    Hidden!

    Re: Q about distribiting software made with GCC

    Quote Originally Posted by NovaAesa View Post
    Yeah, it's that static linking that I'm worried about. For example, I use lots of:

    #include <istream>

    and that kind of thing pretty often. So are these considered "modules" or part of the compiler?

    That's part of the Standard C++ Library, in other words part of the compiler.

    If you were using source code or a library that is not part of the compiler and that library or source code is licensed under GPL and you link statically to that code, you must then license your own program as GPL.

    You can still use GPL code without releasing your program as GPL, but then you cannot link to that code statically, and must link to it dynamically only.

  6. #6
    Join Date
    Apr 2007
    Location
    (X,Y,Z) = (0,0,0)
    Beans
    3,715

    Re: Q about distribiting software made with GCC

    Quote Originally Posted by techmarks View Post
    That's part of the Standard C++ Library, in other words part of the compiler.

    If you were using source code or a library that is not part of the compiler and that library or source code is licensed under GPL and you link statically to that code, you must then license your own program as GPL.

    You can still use GPL code without releasing your program as GPL, but then you cannot link to that code statically, and must link to it dynamically only.
    There are some problems regarding dynamic linking and the GPL. Traditionally, if you dynamic link to GPL code, your code is considered a derivative work and is forced to be GPL too.

    Why? Because when you #include, the preprocessor puts code that's not under your copyright.

    But, the C++ Standard Library is LGPL, which allows to be linked by programs either free or proprietary. The requirement is that you have to allow people access to the library's source (see the license for this; either v2.1 and v3 are stored in /usr/share/common-licenses/).

    None of both apply if you only distribute your own source code and you tell the user to compile. Why? Because the preprocessor hasn't been run... What happens if you link without including a header is not clear to me, but is very improbable to occur.

  7. #7
    Join Date
    May 2008
    Beans
    Hidden!

    Re: Q about distribiting software made with GCC

    Quote Originally Posted by nvteighen View Post
    There are some problems regarding dynamic linking and the GPL. Traditionally, if you dynamic link to GPL code, your code is considered a derivative work and is forced to be GPL too.
    I think you are probably right, and dynamic linking of GPL code is also a derivative work.

    Of course this doesn't apply to the Standard Library.

    If the OP wants freedom as to how he licenses his software, it's best he stay away from linking statically or dynamically to GPL source code or libraries altogether.

  8. #8
    Join Date
    Apr 2007
    Location
    (X,Y,Z) = (0,0,0)
    Beans
    3,715

    Re: Q about distribiting software made with GCC

    I forgot:

    It doesn't matter which license gcc/g++ has. Yes, the compiler is GPL, but what your doing with it is just using it... for what is meant for . The output object code is not linked in anyway to the compiler.

    The same applies for the Linux kernel: the kernel is GPL, but you can develop any non-free application in a Linux system, because your program will just run over the kernel, it doesn't include any part of it (unless you explicitly do that, of course).

    In summary: copyright applies only to the work. Whenever you take a part of that work, you have to ask for permission... but not when you use it.

  9. #9
    Join Date
    May 2008
    Beans
    Hidden!

    Re: Q about distribiting software made with GCC

    The GPL is a poor license because it is so complex.

    The Linux kernel is GPL so that any code statically linked to the kernel must be covered by GPL.

    Companies that develop binary drivers for the kernel get around this by dynamically linking loadable kernel mdules.

    I don't see why dynamically linking to a GPL code should make that program GPL.

    I undestand why static linking to GPL code makes your code GPL.

    But dynamic linking? you are not including that code in your executable and you are not modifying it either, so it seems it should not become GPL.

    But I'm not completely certain, you'll probably have to discuss with a lawyer that is well versed in GPL/open source/patent law.

  10. #10
    Join Date
    Apr 2007
    Location
    (X,Y,Z) = (0,0,0)
    Beans
    3,715

    Re: Q about distribiting software made with GCC

    Oh... I supposed we were talking about libraries...

    If you executable linked somehow to another GPL executable, then nothing should occur because you're not using the GPL code anywhere in yours.

    The problem arrives with GPL libraries, which make you include the header file and thus, you're including code that's not yours.

    OK, I was mistaken: the C++ Standard Library is GPL + linking exception:
    Code:
    // As a special exception, you may use this file as part of a free software
    // library without restriction.  Specifically, if other files instantiate
    // templates or use macros or inline functions from this file, or you compile
    // this file and link it with other files to produce an executable, this
    // file does not by itself 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.
    So, if you just use the library as a dynamic or static library, you are free to place your terms. The last line seems just to be a preemptive protection.

    The obvious question to the GNU guys: Why haven't you used LGPL instead, as in the C Standard Library??

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •