Spec-Zone .ru
спецификации, руководства, описания, API

22.1.3.5. Building Connector/ODBC from a Source Distribution on Unix

Note

Connector/5.2 uses cmake for build, rather than autoconf and its configure command.

You need the following tools to build MySQL from source on Unix:

Once you have all the required files, unpack the source files to a separate directory, then run configure and build the library using make.

Typical cmake Options

iODBC is the default ODBC library used by Connector/ODBC. Alternatively, unixODBC may be used by passing in the appropriate option to cmake. For example:

shell> cmake -G "Unix Makefiles"
        -DWITH_UNIXODBC=1

When you run cmake, you might add options to the command line. Here are some examples:

Additional configure Options

There are a number of other options that you need, or want, to set when configuring the Connector/ODBC driver before it is built.

Build Steps for Unix

To build the driver libraries, execute make:

shell> make

If any errors occur, correct them and continue the build process. If you are not able to build, then send a detailed email to for further assistance.

Building Shared Libraries

On most platforms, MySQL does not build or support .so (shared) client libraries by default. This is based on our experience of problems when building shared libraries.

In cases like this, you have to download the MySQL distribution and configure it with these options:

--without-server --enable-shared

To build shared driver libraries, specify the --enable-shared option for configure. By default, configure does not enable this option.

If you have configured with the --disable-shared option, you can build the .so file from the static libraries using the following commands:

shell> cd
        mysql-connector-odbc-3.51.01shell> makeshell> cd drivershell> CC=/usr/bin/gcc
        \          $CC -bundle -flat_namespace -undefined error \          -o .libs/libmyodbc3-3.51.01.so \          catalog.o
        connect.o cursor.o dll.o error.o execute.o \          handle.o
        info.o misc.o myodbc3.o options.o prepare.o \          results.o
        transact.o utility.o \          -L/usr/local/mysql/lib/mysql/
        \          -L/usr/local/iodbc/lib/
        \          -lz -lc -lmysqlclient
        -liodbcinst

Make sure to change -liodbcinst to -lodbcinst if you are using unixODBC instead of iODBC, and configure the library paths accordingly.

This builds and places the libmyodbc3-3.51.01.so file in the .libs directory. Copy this file to the Connector/ODBC library installation directory (/usr/local/lib, or the lib directory under the installation directory that you supplied with the --prefix option).

shell> cd .libsshell> cp libmyodbc3-3.51.01.so /usr/local/libshell> cd /usr/local/libshell> ln -s
        libmyodbc3-3.51.01.so libmyodbc3.so

To build the thread-safe driver library:

shell> CC=/usr/bin/gcc
        \          $CC -bundle -flat_namespace -undefined
        error          -o .libs/libmyodbc3_r-3.51.01.so          catalog.o connect.o cursor.o dll.o error.o
        execute.o          handle.o info.o misc.o myodbc3.o options.o
        prepare.o          results.o transact.o
        utility.o          -L/usr/local/mysql/lib/mysql/          -L/usr/local/iodbc/lib/          -lz
        -lc -lmysqlclient_r -liodbcinst

Installing Driver Libraries

To install the driver libraries, execute the following command:

shell> make install

That command installs one of the following sets of libraries:

For Connector/ODBC 3.51:

For thread-safe Connector/ODBC 3.51:

For more information on build process, refer to the INSTALL file that comes with the source distribution. Note that if you are trying to use the make from Sun, you may end up with errors. On the other hand, GNU gmake should work fine on all platforms.

Testing Connector/ODBC on Unix

To run the basic samples provided in the distribution with the libraries that you built, use the following command:

shell> make test

Before running the tests, create the DSN 'myodbc3' in odbc.ini and set the environment variable ODBCINI to the correct odbc.ini file; and MySQL server is running. You can find a sample odbc.ini with the driver distribution.

You can even modify the samples/run-samples script to pass the desired DSN, UID, and PASSWORD values as the command-line arguments to each sample.