Documentation Home
MySQL Connector/ODBC Developer Guide
Related Documentation Download this Manual

MySQL Connector/ODBC Developer Guide  /  Connector/ODBC Installation  /  Building Connector/ODBC from a Source Distribution on Unix

4.5 Building Connector/ODBC from a Source Distribution on Unix

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

  • A working ANSI C++ compiler. GCC 4.2.1 or later, Sun Studio 12.1 or later, and many current vendor-supplied compilers are known to work.

  • CMake.

  • MySQL client libraries and include files. To get the client libraries and include files, visit http://dev.mysql.com/downloads/.

  • A compatible ODBC manager must be installed. Connector/ODBC is known to work with the iODBC and unixODBC managers. See Section 3.2, “ODBC Driver Managers” for more information.

  • If you are using a character set that is not compiled into the MySQL client library, install the MySQL character definitions from the charsets directory into SHAREDIR (by default, /usr/local/mysql/share/mysql/charsets). These should be in place if you have installed the MySQL server on the same machine. See Character Sets, Collations, Unicode for more information on character set support.

Once you have all the required files, unpack the source files to a separate directory, then run cmake with the following command:

shell> cmake -G "Unix Makefiles"

Typical cmake Parameters and Options

You might need to help cmake find the MySQL headers and libraries by setting the environment variables MYSQL_INCLUDE_DIR, MYSQL_LIB_DIR, and MYSQL_DIR to the appropriate locations; for example:

shell> export MYSQL_INCLUDE_DIR=/usr/local/mysql/include
shell> export MYSQL_LIB_DIR=/usr/local/mysql/lib
shell> export MYSQL_DIR=/usr/local/mysql

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

  • -DODBC_INCLUDES=dir_name: Use when the ODBC include directory is not found within the system $PATH.

  • -DODBC_LIB_DIR=dir_name: Use when the ODBC library directory is not found within the system $PATH.

  • -DWITH_UNIXODBC=1: Enables unixODBC support. iODBC is the default ODBC library used when building Connector/ODBC from source on Linux platforms. Alternatively, unixODBC may be used by setting this option to 1.

  • -DMYSQLCLIENT_STATIC_LINKING=boolean: Link statically to the MySQL client library. Since release 5.3.10, when building Connector/ODBC from sources, dynamic linking with the MySQL client library is selected by default—that is, the MYSQLCLIENT_STATIC_LINKING cmake option is FALSE by default (however, the binary distributions of Connector/ODBC from Oracle are linked statically to the client library). If you want to link statically to the MySQL client library, set the option to TRUE. See also the description for the -DMYSQLCLIENT_LIB_NAME=client_lib_name_with_extension option.

  • -DMYSQLCLIENT_LIB_NAME=client_lib_name_with_extension: Location of the MySQL client library. See the description for MYSQLCLIENT_STATIC_LINKING. For release 5.3.10 and later, if you want to link statically to the MySQL client library, use this option to supply the client library's name for static linking. Also use this option If you want to link dynamically to a MySQL client library other than libmysqlclient.so. cmake looks for the client library under the location specified by the environment variable MYSQL_LIB_DIR; if the variable is not specified, cmake looks under the default locations inside the folder specified by the environment variable MYSQL_DIR.

  • -DMYSQL_CONFIG_EXECUTABLE=/path/to/mysql_config: Specifies location of the utility mysql_config, which is used to fetch values of the variables MYSQL_INCLUDE_DIR, MYSQL_LIB_DIR, MYSQL_LINK_FLAGS, and MYSQL_CXXFLAGS. Values fetched by mysql_config are overridden by values provided directly to cmake as parameters.

  • -DMYSQL_LINK_FLAGS=MySQL link flags

  • -DMYSQL_CXXFLAGS=MySQL C++ linkage flags

  • -DMYSQL_CXX_LINKAGE=1: Enables C++ linkage to MySQL client library. By default, MYSQL_CXX_LINKAGE is enabled for MySQL 5.6.4 or later. For MySQL 5.6.3 and earlier, this option must be set explicitly to 1.

Build Steps for Unix

To build the driver libraries, execute make:

shell> make

If any errors occur, correct them and continue with the build process. If you are not able to finish the build, see Section 9.1, “Connector/ODBC Community Support”.

Installing Driver Libraries

To install the driver libraries, execute the following command:

shell> make install

For more information on build process, refer to the BUILD file that comes with the source distribution.

Testing Connector/ODBC on Unix

Some tests for Connector/ODBC are provided in the distribution with the libraries that you built. To run the tests:

  1. Make sure you have an odbc.ini file in place, by which you can configure your DSN entries. A sample odbc.ini file is generated by the build process under the test folder. Set the environment variable ODBCINI to the location of your odbc.ini file.

  2. Set up a test DSN in your odbc.ini file (see Section 5.5, “Configuring a Connector/ODBC DSN on Unix” for details ). A sample DSN entry, which you can use for your tests, can be found in the sample odbc.ini file.

  3. Set the environment variable TEST_DSN to the name of your test DSN.

  4. Set the environment variable TEST_UID and perhaps also TEST_PASSWORD to the user name and password for the tests, if needed. By default, the tests use root as the user and do not enter a password; if you want the tests to use another user name or password, set TEST_UID and TEST_PASSWORD accordingly.

  5. Make sure that your MySQL server is running.

  6. Run the following command:

    shell> make test


User Comments
Sign Up Login You must be logged in to post a comment.