MySQL++

Changes To FAQ
Login

Changes To FAQ

Changes to "FAQ" between 2017-06-29 00:27:52 and 2017-06-29 00:33:22

78
79
80
81
82
83
84
85

86
87
88
89
90

91
92
93
94
95
96

97
98
99
100
101
102
103
78
79
80
81
82
83
84

85
86
87
88
89

90
91
92
93
94
95

96
97
98
99
100
101
102
103







-
+




-
+





-
+








MySQL++ can be made to build against MySQL 3.23, but it won’t do so out
of the box. The last time I tried this, the only thing that needed doing
was changing `MYSQL_TYPE_`\* in `lib/type_info.cpp` to `FIELD_TYPE_`\*.
The UTF-8 comments above also apply equally to older versions of MySQL.


## Does it build against [MariaDB](https://mariadb.org)?<a name="mariadb"></a>
## <a name="mariadb"></a>Does it build against [MariaDB](https://mariadb.org)?

Yes. The library is only called “MySQL++” because it predates MariaDB.


## What software license does MySQL++ use? Is it free?<a name="license"></a>
## <a name="license"></a>What software license does MySQL++ use? Is it free?

MySQL++ is free software, licensed under the [GNU
LGPL](http://www.gnu.org/licenses/lgpl.html).


## What does the LGPL license mean to me, as far as MySQL++ goes?<a name="whylgpl"></a>
## <a name="whylgpl"></a>What does the LGPL license mean to me, as far as MySQL++ goes?

The common wisdom regarding LGPL’d libraries is that you can use them
with a program using almost any software license as long as you’re
willing to link dynamically. Think of the GNU C library (glibc) on
Linux: it’s LGPL’d and linked to almost everything on a Linux system, at
least indirectly. If your program’s software license allows dynamic
linking to glibc, it should allow you to use MySQL++ dynamically, too.
118
119
120
121
122
123
124
125

126
127
128
129
130
131
132
118
119
120
121
122
123
124

125
126
127
128
129
130
131
132







-
+








If you need to link to your C++ database library statically and can’t
use the LGPL or something compatible with it for your program, you might
consider using MySQL’s Connector/C++ instead. The free version is GPL’d,
but they will sell you a commercial license which allows static linking.


## Doesn’t the MySQL C API library’s GPL license override MySQL++’s LGPL license?<a name="mysqlclientgpl"></a>
## <a name="mysqlclientgpl"></a>Doesn’t the MySQL C API library’s GPL license override MySQL++’s LGPL license?

The MySQL C API library is available under *two* different licenses, not one.

The default license for MySQL (including its C API library) is GPL with
the FOSS license exception. This is what you get if you got MySQL for
free, such as by downloading it from `mysql.com` or as part of your
Linux distro. The less liberal distribution terms of the C API library’s
142
143
144
145
146
147
148
149

150
151
152
153
154
155
156
142
143
144
145
146
147
148

149
150
151
152
153
154
155
156







-
+







This issue really has nothing to do with MySQL++. The same restriction
applies if you write your program directly against the C API library.
The only reason I even put this here is because people keep asking the
question. Please work out the licensing with MySQL, Inc. Having settled
that, the previous FAQ item applies.


## How does MySQL++ compare to MySQL’s Connector/C++?<a name="conncpp"></a>
## <a name="conncpp"></a>How does MySQL++ compare to MySQL’s Connector/C++?

[Connector/C++](https://dev.mysql.com/downloads/connector/cpp/) is a much
younger C++ wrapper for the MySQL C API library, fully developed under
the MySQL corporate aegis. By contrast, MySQL++ has a long, complex
[development history](doc/html/userman/index.html#history). MySQL++
started out as a third-party library, was maintained and enhanced by
MySQL for several years, then got spun back out again, this time
170
171
172
173
174
175
176
177

178
179
180
181
182
183
184
185
186

187
188
189
190
191
192
193
170
171
172
173
174
175
176

177
178
179
180
181
182
183
184
185

186
187
188
189
190
191
192
193







-
+








-
+







features heavily. If you are a Java developer or simply admire its
database interface design, you may prefer Connector/C++.

Another way to look at it is that Connector/C++ is new and therefore
perhaps less crufty, while MySQL++ is mature and featureful.


## Will it build under GCC?<a name="gcc"></a><a name="gcc2"></a>
## <a name="gcc"><a name="gcc2"></a></a>Will it build under GCC?

Yes, with GCC version 3.0 and up, except on [MinGW](#mingw), which requires 3.4.5 at minimum.

The last version of MySQL++ that works with GCC 2.95.*x* is 1.7.9. It may be less painful to port the current version back to GCC 2.95 than to live with the limitations and bugs of this older version. The main thing breaking this backwards compatibility are the steps forward we’ve taken for Standard C++ compliance. If you work around or revert these, it should work on GCC 2.95 again.

If you’re stuck on anything older than GCC 2.95, we recommend that you use the MySQL C API instead of trying to arm-twist MySQL++ into building under it.


## Will it build under Visual C++?<a name="vstudio"></a>
## <a name="vstudio"></a>Will it build under Visual C++?

Yes, it ships with project files for Visual C++ 2005 and 2008.

MySQL++ also works fine with Visual C++ 2010 and newer with a project
file conversion. This may require minor manual adjustments. For example,
when VC++ 2013 converts the VS2008 project files, it changes the debug
build output directory from `debug` to `debug\x64` but fails to update
205
206
207
208
209
210
211
212

213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228

229
230
231
232
233

234
235
236
237
238

239
240
241
242
243
244
245

246
247
248
249
250
251
252
253
254
255

256
257
258
259
260
261
262
263
264

265
266
267
268
269
270
271
272
273
274
275

276
277
278
279
280
281
282
205
206
207
208
209
210
211

212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227

228
229
230
231
232

233
234
235
236
237

238
239
240
241
242
243
244

245
246
247
248
249
250
251
252
253
254

255
256
257
258
259
260
261
262
263

264
265
266
267
268
269
270
271
272
273
274

275
276
277
278
279
280
281
282







-
+















-
+




-
+




-
+






-
+









-
+








-
+










-
+







consider upgrading as the compliance of the compiler has improved
greatly. The [Community
edition](https://www.visualstudio.com/vs/community/) now does pretty
much everything the pre-2015 Professional editions used to, so you may
no longer have a valid excuse for not upgrading.


## Will it build on Mac OS X/macOS?<a name="osx"></a><a name="xcode"></a>
## <a name="osx"><a name="xcode"></a></a>Will it build on Mac OS X/macOS?

Yes, it builds just fine, both from within the Xcode environment and at
the command line. We currently test only on the current and/or prior
releases of the OS. The included Xcode project files should work with
Xcode 2+, which implies that it may still build on systems as old as OS
X 10.4. In the past, we successfully tested command line builds on a
10.3 box.

Command line builds are still preferred to Xcode, as there is more
flexibility to be had here. See `README-Mac-OS-X.txt` in the MySQL++
tarball for details. That file also contains instructions on getting
[Connector/C](https://dev.mysql.com/downloads/connector/c/) for OS X,
which MySQL++ builds against.


## Will it build under Cygwin?<a name="cygwin"></a>
## <a name="cygwin"></a>Will it build under Cygwin?

Yes. See [the `README-Cygwin.txt` file](/file/README-Cygwin.txt).


## Will it build under MinGW?<a name="mingw"></a>
## <a name="mingw"></a>Will it build under MinGW?

Yes. Occasionally a version of MinGW comes out that breaks MySQL++, but there has always been a usable workaround.


## Will it build under Solaris?<a name="solaris"></a>
## <a name="solaris"></a>Will it build under Solaris?

Yes, we have reports of people building it successfully on versions as old as Solaris 8. It gets the most testing with GCC, but we have heard occasional success reports from people using Sun CC. I’ve personally only built it with GCC under OpenSolaris 2008.05 and 2008.11.

Just use the built-in package manager to install MySQL 5.0 or newer and GCC, and you’re set. Beware, in some versions of Solaris, the “mysql” package is MySQL 4.0, which MySQL++ no longer works 100% with out of the box. (See above.) You want the “mysql5” package instead.


## Will it build under C++Builder?<a name="borland"></a>
## <a name="borland"></a>Will it build under C++Builder?

It can be made to work, mostly.

The last time it was tried, the [Specialized SQL Structures](doc/html/userman/ssqls.html) feature didn’t work right out of the box due to a compiler limitation. A full discussion of the
problem and possible workarounds is in [this mailing list message](http://lists.mysql.com/plusplus/4307).

That was back in the Borland days, so if you’ve verified functionality under one of the newer Embarcadero releases, we’d appreciate a report on the mailing list.


## `g++ simple1.cpp -o simple1`?<a name="hownottobuild"></a>
## <a name="hownottobuild"></a>`g++ simple1.cpp -o simple1`?

No!

You’re probably missing a `-I` flag for the MySQL++ headers, and you’re certainly missing [correct link flags](#linkerrors).

The user manual has a [section](doc/html/userman/incorporating.html#inc-unix) that describes how to build a program based on MySQL++.


## It compiles, but it won’t link! Why?<a name="linkerrors"></a>
## <a name="linkerrors"></a>It compiles, but it won’t link! Why?

To build any program using MySQL++, at minimum you must link to the MySQL++ library and also to the MySQL C API library that MySQL++ is built upon. The MySQL++ library is `libmysqlpp.so` on Unixy systems, and `mysqlpp.lib` on Windows. The MySQL C API library is either `libmysqlclient{_r}.{a,so}` on Unixy systems and `libmysql.lib` on
Windows.

**Visual C++**: An additional requirement with Visual C++ is that you must link to the same C Run-Time Library (RTL) for all modules throughout your project. The Visual C++ project files that come with MySQL++ use the multithreaded DLL version (`/MD` or `/MDd`) of the C RTL. If you link MySQL++ to a program or additional third party library
that uses a different RTL, you will get link errors. Study the example projects’ settings to see how this is done. The instructions in the `README-Visual-C++.txt` file may also be helpful.

See [Chapter 9, Using MySQL++ in Your Own Project](doc/html/userman/incorporating.html) in the [MySQL++ User Manual](doc/html/userman/) for more on this.


## Why is my program leaking memory?<a name="memleak"></a>
## <a name="memleak"></a>Why is my program leaking memory?

The current version of MySQL++ has no known memory leaks. If you free all of the MySQL++ objects you allocate, it should not be leaking memory.

If you’re getting a report from a memory debugger about a leak, most
likely you’re seeing memory that the MySQL C API library allocates for
its own internal purposes. MySQL++ is built atop this library, so it can
look like it’s MySQL++ leaking the memory. This underlying C library
309
310
311
312
313
314
315
316

317
318
319
320
321
322
323
324
325
326
327
328

329
330
331
332
333

334
335
336
337
338
339
340
341

342
343
344
345
346
347
309
310
311
312
313
314
315

316
317
318
319
320
321
322
323
324
325
326
327

328
329
330
331
332

333
334
335
336
337
338
339
340

341
342
343
344
345
346
347







-
+











-
+




-
+







-
+






Until you can establish this link, it’s premature to post to the MySQL++
mailing list claiming there’s a leak in MySQL++. Even if you can
establish such a link, it’s far more likely that you’re not releasing
the MySQL++ objects you allocate than MySQL++ itself failing to release
memory.


## My program is crashing. Help!<a name="segfaults"></a>
## <a name="segfaults"></a>My program is crashing. Help!

The most common cause of crashes in MySQL++ is uncaught exceptions. The library throws exceptions when it detects errors, such as invalid SQL syntax, invalid login parameters, etc. Try running the example programs, since they all catch exceptions properly.

If the examples also crash and you’re using a package built for a
different Linux distribution than the one you’re actually running, try
rebuilding the package from [source](#source) on the target OS. A binary
package is fairly closely tied to the system it is built under, so it’s
possible that RPMs you build on your system will work better than those
built elsewhere.


## Nothing’s working at all! Is it broken?<a name="broken"></a>
## <a name="broken"></a>Nothing’s working at all! Is it broken?

Maybe, but have you tried running the examples? Follow the instructions in the `README-examples.txt` file. If the examples work but your program doesn’t, chances are good that the error is in your program; study the examples, and [read the manuals](/wiki?name=Documentation). If the examples also fail to work, post to the mailing list with a detailed failure report.


## I’m sure I’ve found a bug. How do I submit a report?<a name="bugreport"></a>
## <a name="bugreport"></a>I’m sure I’ve found a bug. How do I submit a report?

We’ll want some code that demonstrates the bug. No doubt you’d rather not send us a copy of your database to demonstrate the problem, and to be frank, we don’t want your database, either. The best thing is to modify one of the MySQL++ examples so that it reproduces the problem you’re seeing. This lets the people that can help you reproduce the problem on their machines, without needing your database.

Once you have your problem boiled down to a simple example, send the source code to the mailing list along with a detailed report. We want to know what you expect the program to do, and what it actually does on your machine. Keep in mind, programs often behave differently on different systems. As a programmer yourself, you know what it is like to
deal with vague user bug reports. Give us the sort of error report you’d like to receive for your programs.


## How do I submit a change to MySQL++?<a name="patches"></a>
## <a name="patches"></a>How do I submit a change to MySQL++?

This is covered in detail in [the `HACKERS.txt` file](/file/HACKERS.txt).

But in brief: we want the patch in unified diff format, made against either the latest release of MySQL++ or (preferably) against the trunk of the [Fossil repository](/files). You can send it either to the [mailing list](http://lists.mysql.com/plusplus/), or to [the ticket tracker](/ticket). We prefer that you only use the ticket tracker for patches that are so trivial or obvious that they won’t need discussion.

When a patch is rejected, the most common reason is that it breaks the library’s binary interface (ABI), so that an old program can’t link to the changed library without recompiling. We only make such changes at major version transitions. These transitions are rare, and we can’t even promise that there will ever be another one, much less when it will occur. If you have a choice of two ways to get your desired effect and one of them doesn’t break the ABI, it will increase the chances that we accept your patch if you do it that way.