8. Configuring MySQL++
Prev |  | Next

## 8. Configuring MySQL++

The default configuration of MySQL++ is suitable for most purposes, but there are a few things you can change to make it meet special needs.

### 8.1. The Location of the MySQL Development Files

MySQL++ is built on top of the MySQL C API. It relies on this low-level library for all communication with the database server. Consequently, the build process for MySQL++ may fail if it can’t find the C API headers and library.

On platforms that use Autoconf[15], the `configure` script can usually figure out the location of the C API development files by itself. It simply tries a bunch of common installation locations until it finds one that works. If your MySQL server was installed in a nonstandard location, you will have to tell the `configure` script where these files are with some combination of the `--with-mysql`, `--with-mysql-include`, and `--with-mysql-lib` flags. See `README-Unix.txt` for details.

No other platform allows this sort of auto-discovery, so the build files for these platforms simply hard-code the default installation location for the current Generally Available version of MySQL. For example, the Visual C++ project files currently assume MySQL is in `c:\Program Files\MySQL\MySQL Server 5.0`. If you’re using some other release of MySQL or you installed it in a nonstandard location, you will have to modify the build files. How you do this, exactly, varies based on platform and what tools you have on hand. See `README-Visual-C++.txt`, `README-MinGW.txt`, or `README-Mac-OS-X.txt`, as appropriate.

### 8.2. The Maximum Number of Columns Allowed

MySQL++ offers two ways to automatically build SQL queries at run time: Template Queries and SSQLS. There’s a limit on the number of template query parameters and the number of SSQLS fields, due to the way these mechanisms work. Both are set to 25, by default. We arrived at these limits empirically, partly by looking at good database designs, and by testing compilers to find their limits. We wanted a limit that doesn’t often need to be raised without unduly narrowing the list of supported platforms by exceeding compiler limits.

If it happens that your database design does need more than 25 columns or template query parameters, first look to see if there’s a good way to change the design. It’s usually a sign of too many unrelated things in one table if you need so many columns. If you decide the design is good, you can raise these limits by re-generating the `lib/ssqls.h` and/or `lib/querydef.h` headers using Perl scripts with the same name, except with a `pl` extension. Instructions for this are at the top of each script.

If you’re on a platform that uses Autoconf[16], you can change these scripts like you would any other part of the library. After making your changes, just say make to rebuild the library, including these headers. This requires a Perl interpreter on the system to work, but Perl is nearly ubiquitous on systems that also use autoconf these days.

On all other platforms, you’ll have to rebuild these headers by running Perl by hand. Just say perl ssqls.pl or perl querydef.pl in the `lib` subdirectory of the MySQL++ sources, then build the library as you normally would.

### 8.3. Buried MySQL C API Headers

It’s common these days on Unixy systems to install the MySQL C API headers in a `mysql` directory under some common `include` directory. If the C API headers are in `/usr/include/mysql`, we say they are “buried” underneath the system’s main include directory, `/usr/include`. Since the MySQL++ headers depend on these C API headers, it can be useful for MySQL++ to know this fact.

When MySQL++ includes one of the C API headers, it normally does so in the obvious way:

    #include <mysql.h>

But, if you define the `MYSQLPP_MYSQL_HEADERS_BURIED` macro, it switches to this style:

    #include <mysql/mysql.h>

In common situations like the `/usr/include/mysql` one, this simplifies the include path options you pass to your compiler.

### 8.4. Building MySQL++ on Systems Without Complete C99 Support

MySQL++ uses the C99 header `stdint.h` for portable fixed-size integer typedefs where possible. The C99 extensions aren’t yet officially part of the C++ Standard, so there are still some C++ compilers that don’t offer this header. MySQL++ works around the lack of this header where it knows it needs to, but your platform might not be recognized, causing the build to break. If this happens, you can define the `MYSQLPP_NO_STDINT_H` macro to make MySQL++ use its best guess for suitable integer types instead of relying on `stdint.h`.

MySQL++ also uses C99’s long long data type where available. MySQL++ has workarounds for platforms where this is known not to be available, but if you get errors in `common.h` about this type, you can define the macro `MYSQLPP_NO_LONG_LONGS` to make MySQL++ fall back to portable constructs.

[15] Linux, Solaris, the BSDs, Mac OS X command line (as opposed to the Xcode IDE), Cygwin... Basically, Unix or anything that works like it.

[16] ditto

Prev |  | Next
7. Using MySQL++ in a Multithreaded Program | Home | 9. Using MySQL++ in Your Own Project