views:

113

answers:

3

I want to run queries on my MySQL server through a C++ program that will be released to the public for free, but not under the GPL or any other open-source license.

My first question is if I can use the MySQL Connector/C++ library in my application.

If not, then what alternatives are there for me to use?

A: 

Okay, you can use this: http://forge.mysql.com/wiki/Connector_C%2B%2B

But fair warning: it sucks. Just read the MySQL connector forums, it's pretty amusing how awful this connector is.

Or you can use this: http://tangentsoft.net/mysql++/

It's much better, but still kind of sucks.

My personal experience with MySQL and C++ has been a nightmare. I'm currently re-writing a dispatch server in Java because I just can't handle the memory leaks, malloc crashes, segfaults, etc, etc. I could have went the C route and just used the C connector (which is quite stable, I hear), but I'm not writing stuff in an object oriented language to have to use C libraries.

As far as the license is concerned, you're out of luck. You have to get a license to sell your commercial application if it uses a MySQL connector (C or C++).

You could, however, use an MIT (or equivalent) ODBC API which (I think) should allow you to release/sell commercial and closed-source software that has MySQL capability (through a driver, not native).

David Titarenco
No, you cannot use those libraries in a non-open-source application because they link to original MySQL C API and thus are derivative work.
Vlad Lazarenko
Yes of course, that's why he's out of luck :)
David Titarenco
-1, can you explain why please? I offer two mysql libraries and I also explain the library situation and offer a solution (ODBC).
David Titarenco
Both C++ libraries you mention are built on top of MySQL's C API library, so neither gets you around the GPL problem in the question. You answer is simply incorrect, and so earns a -1.
Warren Young
... I clearly say that using any connector/C library doesn't get him around the GPL problem. Did you get to my 3rd and 4th paragraphs?
David Titarenco
As I read the question, the GPL issue is a showstopper. If you change your answer to recommend only ODBC, I could remove my downvote in good conscience. If you want to talk about MySQL++ and Connector/C++ in your answer, drop the polemics, and just say why the poster can't use them to solve the problem as given. (You can drop the manual memory management polemic, too. It's also off-topic.) The proper place to criticize these libraries is their mailing lists. I've checked their archives, and there are no posts from David Titarenco on either.
Warren Young
The question is titled "Accessing MySQL through C++", so I'd argue that the connector discussion is relevant, but to each their own. I'm glad that you did some online Sherlock Holming, but I never claimed to have posted on either mailing list (lol?)...It just seems you're mad about something and I don't think getting into a puerile argument on SO is my kinda' thang - 1 rep point really isn't worth it.
David Titarenco
Sure, the question's title could be clearer. But since you're supposed to be answering what was asked, not how it was titled, that's how I voted. As for the mailing list issue, obviously I'm aware that you didn't claim to post there. My point is that that's where discussion of these libraries flaws belongs. MySQL++ and Connector/C++ are not the right answer to this question, so this is not the right place to discuss their flaws. If you want the problems to be fixed, post to the lists. If you just want to flame, do it on your blog or something.
Warren Young
+3  A: 

Unfortunately, MySQL has changed client libraries licenses from LGPL to GPL which means that any application linking with those libraries statically or dynamically becomes a derivative work. Therefore, you cannot use MySQL client libraries (that are used to access MySQL server) in non-FOSS applications unless you purchase a license for that. A FOSS here stands for Free & Open Source. A list of FOSS licenses recognized by Oracle, the owner of MySQL, can be found here.

However, you can use ODBC to access MySQL without distributing any MySQL libraries etcetera, so client is responsible for that and have to decide whether to use Open Source or commercial MySQL license, which does not obligate you to purchase any licenses or distribute your software under FOSS license recognized by Oracle. Read this article for more details.

Another interesting part about GPL is that it states that application that links to a GPL library is a derivative work. It means that if you will make a minimalistic open source application that links to MySQL client libraries and communicates with MySQL server, defines an API interface and dynamically loads your commercial/closed-source library which will export only that defined API implementation, you will not violate license terms and conditions because in that case open source application will be a user of closed-source product. The same approach is used by commercial graphics drivers (like NVidia) and audio codecs (like MP3).

Vlad Lazarenko
A: 

The safest bet is probably to use the ODBC connector as Vlad suggested, but that's really just pushing the licensing headache down to your clients/users (ie: it's up to them to verify that the usage is correct with respect to the various licenses). In concept it might be fine for an application with any license to use an ODBC driver which is licensed under the GPL as long as it's not statically linked (that is, it's dynamically loaded based on a connection string), but one could argue that the user was then violating the GPL by causing the application to use the GPL component in violation of the usage license for the GPL component (since the application was not also available under the GPL). It can get messy, and it's not generally legally clear-cut: you may be safe, but your users may be in violation in any real-world usage scenario.

My advice would be to avoid anything GPL is you're not using it for your own app (and everything else you're using), and you can avoid it; there's a good reason why lots of people avoid GPL-ed software like the plague. If you're writing on Windows, just use SQL Server Express with the regular MDAC connectors: they are both free, readily available, performant, and place no particular restrictions or rights management on your code (unlike GPL libraries). For Linux, I don't know, but I'm sure there are alternatives.

Nick