Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I know this question has been asked here before, and I also know that this website is for programming questions only, but please do make an exception, as none of the posts I've come across on this site, or others, have answered this question properly (there are too many ifs).

I'm planning to develop a program which I intend to sell later. I'm trying to decide upon a language to code it with, and have narrowed down to C++ or Java.

I've been through the GPL v2 and v3 licenses used for GNU's GCC and OpenJDK (yes, I can understand some amount of legal stuff, but clearly, not all of it). But there is one point upon which everyone is obscure (this should have been one of the first things answered, IMO): if I develop a program using C++/Java and compile it using GCC compiler or OpenJDK's compiler, can I sell it without having to place my program under GPL as well?

As far as I can make out, I have full rights to assign any license to my program, but, there is a catch: it says in the license that I shouldn't link to any library that is under GPL. If so, I'll have to release my program under GPL.

Now, I don't know what in C++/Java is considered a library, so if I use the normal stuff in C++ (iostream, list, map, etc. ) or the normal Java classes/interfaces available as part of the standard JDK 6 distribution (String, List, Map, etc.), does this constitute 'linking to the libraries'?

share|improve this question

migrated from stackoverflow.com Apr 18 '11 at 15:13

This question came from our site for professional and enthusiast programmers.

    
1. We don't do legal advice around here. 2. What is 'C++/Java'? 3. Look around and see thousands and thousands of commercial software products written in Java, many with JNI components. –  bmargulies Apr 16 '11 at 19:23
1  
The / in C++/Java is just being used as an abbreviation for "or", which is perfectly valid English. –  Robin Green Apr 17 '11 at 9:01
add comment

5 Answers

The OpenJDK is GPL'd but with an exception for linking to libraries. http://en.wikipedia.org/wiki/OpenJDK

Using OpenJDK classes would constitute linking to a library I would think (rt.jar).

A library in that context, from the point of view of Java, is surely a dependency jar, war, class, etc. Anyway, I'm sure you can legally sell a Java app - there's more than a few out there that Oracle/Sun haven't taken legal action over.

share|improve this answer
    
The same is true of libstdc++ - it also has an exception. –  Robin Green Apr 16 '11 at 19:34
    
Both rt.jar and libstdc++ are implementations of a specification that is not GPL. Essentially, if I linked my application against a non-GPL'd version of libstdc++ it would function identically (assuming the spec was implemented properly) in both versions. The fact that a platform dynamically loads a GPL'd version of the library doesn't count against your app. You wrote to the platform standard, and are covered under whatever license you want. –  Berin Loritsch Apr 18 '11 at 15:32
add comment

Don't worry, this is a computer programming question, or at least one that closely concerns programmers.

From what i know, if you create software that is linked with some GPL code, you have to release your source code if you distribute your program.

That does not mean that you have to release your code to sourceforge i.e. But if a third party asks you for the code, you have to provide it.

share|improve this answer
    
That point is not relevant because the activity described in the question does not, other things being equal, involve linking to GPL code. –  Robin Green Apr 16 '11 at 19:24
    
The Question above : if I develop a program using C++/Java and compile it using GCC compiler or OpenJDK's compiler, can I sell it without having to place my program under GPL as well? –  SpyrosP Apr 16 '11 at 19:26
    
I think i'm clearly specifying that if you USE GPL code, you have to release. –  SpyrosP Apr 16 '11 at 19:27
    
Sorry, I was inaccurate - it does in some cases involve linking to GPLed code in some sense, but e.g. the Classpath exception applies, so you don't have to release your code under the GPL. –  Robin Green Apr 16 '11 at 19:31
    
ahh,ok then, didn't know about that –  SpyrosP Apr 16 '11 at 19:32
add comment

if I develop a program using C++/Java and compile it using GCC compiler or OpenJDK's compiler, can I sell it without having to place my program under GPL as well?

Yes. The GPL specifically excludes the output of running the program:

the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program).

which means that if you include bits of GCC or something else GPLed in your program, then yes it would have to be GPLed, otherwise no - the fact that its object code was produced by a GPLed compiler is not relevant to whether it should be GPLed.

All the standard language libraries you would link to are either not GPLed, or are GPLed but have a special exception to allow your proprietary software to link to them, if you do not modify them. In the case of C++ I mean libgcc, glibc and libstdc++; in the case of Java I mean all the libraries included in the JRE.

Technically, you can legally sell GPL software anyway, but almost no-one makes any money out of doing so.

share|improve this answer
    
The LGPL (Lesser GPL) allows an application to link to it without requiring that application to be GPLd itself. A GPL library on the other hand is infectious. But you are correct, the output of the compiler is explicitly excluded from the GPL terms. –  Berin Loritsch Apr 18 '11 at 15:29
    
and what if i modify the standard language libraries? can i do it? what happens to license of my program then? –  piotrek Sep 29 '13 at 0:10
    
Then the exception does not apply and you have to follow the full terms of the relevant license. Also, there are trademark implications in the case of Java - better not mention Java or OpenJDK in your documentation or advertising at all if you are using it (but see the Oracle v Google court case). –  Robin Green Sep 29 '13 at 9:12
add comment

Both GCC and OpenJDK have explicit exceptions:

… When you use GCC to compile a program, GCC may combine portions of certain GCC header files and runtime libraries with the compiled program. The purpose of this Exception is to allow compilation of non-GPL (including proprietary) programs to use, in this way, the header files and runtime libraries covered by this Exception. …

… When GNU Classpath is used unmodified as the core class library for a virtual machine, compiler for the java languge, or for a program written in the java programming language it does not affect the licensing for distributing those programs directly …

share|improve this answer
add comment

It isn't obscure. There's an exception to the license that applies here. This is findable from the appropriate question in the GPL FAQ.

In short, what you want to do is permissible.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.