[+/-]
You need the following tools to build MySQL from source on Unix:
A working ANSI C++ compiler. gcc 2.95.2 or later, SGI C++, and SunPro C++ are some of the compilers that are known to work.
A good make program. GNU make is always recommended and is sometimes required.
MySQL client libraries and include files from MySQL 4.0.0 or higher. (Preferably MySQL 4.0.16 or higher). This is required because Connector/ODBC uses new calls and structures that exist only starting from this version of the library. To get the client libraries and include files, visit http://dev.mysql.com/downloads/.
If you have built your own MySQL server and/or client
libraries from source then you must have used the
--enable-thread-safe-client
option to configure
when the libraries
were built.
You should also ensure that the
libmysqlclient
library were built and
installed as a shared library.
A compatible ODBC manager must be installed. Connector/ODBC
is known to work with the iODBC
and
unixODBC
managers. See
Section 21.1.2.1.2, “ODBC Driver Managers”, for more
information.
If you are using a character set that isn't compiled into
the MySQL client library then you need to 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 Section 9.1, “Character Set Support”,
for more information on character set support.
Once you have all the required files, unpack the source files to a separate directory, you then have to run configure and build the library using make.
The configure script gives you a great deal of control over how you configure your Connector/ODBC build. Typically you do this using options on the configure command line. You can also affect configure using certain environment variables. For a list of options and environment variables supported by configure, run this command:
shell> ./configure --help
Some of the more commonly used configure options are described here:
To compile Connector/ODBC, you need to supply the MySQL
client include and library files path using the
--with-mysql-path=
option, where DIR
DIR
is the
directory where MySQL is installed.
MySQL compile options can be determined by running
.
DIR
/bin/mysql_config
Supply the standard header and library files path for your
ODBC Driver Manager (iODBC
or
unixODBC
).
If you are using iODBC
and
iODBC
is not installed in its
default location (/usr/local
),
you might have to use the
--with-iodbc=
option, where DIR
DIR
is the
directory where iODBC
is installed.
If the iODBC
headers do not reside
in
,
you can use the
DIR
/include--with-iodbc-includes=
option to specify their location.
INCDIR
The applies to libraries. If they are not in
,
you can use the
DIR
/lib--with-iodbc-libs=
option.
LIBDIR
If you are using unixODBC
, use the
--with-unixODBC=
option (case sensitive) to make
configure look for
DIR
unixODBC
instead of
iODBC
by default,
DIR
is the directory where
unixODBC
is installed.
If the unixODBC
headers and
libraries aren't located in
and
DIR
/include
,
use the
DIR
/lib--with-unixODBC-includes=
and
INCDIR
--with-unixODBC-libs=
options.
LIBDIR
You might want to specify an installation prefix other
than /usr/local
. For example, to
install the Connector/ODBC drivers in
/usr/local/odbc/lib
, use the
--prefix=/usr/local/odbc
option.
The final configuration command looks something like this:
shell>./configure --prefix=/usr/local \
--with-iodbc=/usr/local \
--with-mysql-path=/usr/local/mysql
There are a number of other options that you need, or want, to set when configuring the Connector/ODBC driver before it is built.
To link the driver with MySQL thread safe client libraries
libmysqlclient_r.so
or
libmysqlclient_r.a
, you must specify
the following configure option:
--enable-thread-safe
and can be disabled (default) using
--disable-thread-safe
This option enables the building of the driver thread-safe
library libmyodbc3_r.so
from by
linking with MySQL thread-safe client library
libmysqlclient_r.so
(The extensions
are OS dependent).
If the compilation with the thread-safe option fails, it
may be because the correct thread-libraries on the system
could not be located. You should set the value of
LIBS
to point to the correct thread
library for your system.
LIBS="-lpthread" ./configure ..
You can enable or disable the shared and static versions of Connector/ODBC using these options:
--enable-shared[=yes/no] --disable-shared --enable-static[=yes/no] --disable-static
By default, all the binary distributions are built as
nondebugging versions (configured with
--without-debug
).
To enable debugging information, build the driver from
source distribution and use the
--with-debug
option when
you run configure.
This option is available only for source trees that have been obtained from the Subversion repository. This option does not apply to the packaged source distributions.
By default, the driver is built with the
--without-docs
option. If you would like
the documentation to be built, then execute
configure with:
--with-docs
To build the driver libraries, you have to just execute make.
shell> make
If any errors occur, correct them and continue the build
process. If you aren't able to build, then send a detailed
email to <myodbc@lists.mysql.com>
for further
assistance.
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, you must 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.01
shell>make
shell>cd driver
shell>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
).
shell>cd .libs
shell>cp libmyodbc3-3.51.01.so /usr/local/lib
shell>cd /usr/local/lib
shell>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
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:
libmyodbc3.so
libmyodbc3-3.51.01.so
, where 3.51.01
is the version of the driver
libmyodbc3.a
For thread-safe Connector/ODBC 3.51:
libmyodbc3_r.so
libmyodbc3-3_r.51.01.so
libmyodbc3_r.a
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.
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.
To build the driver on Mac OS X (Darwin), make use of the following configure example:
shell>./configure --prefix=/usr/local
--with-unixODBC=/usr/local
--with-mysql-path=/usr/local/mysql
--disable-shared
--enable-gui=no
--host=powerpc-apple
The command assumes that the unixODBC
and
MySQL are installed in the default locations. If not,
configure accordingly.
On Mac OS X, --enable-shared
builds
.dylib
files by default. You can build
.so
files like this:
shell>make
shell>cd driver
shell>CC=/usr/bin/gcc \
$CC -bundle -flat_namespace -undefined error
-o .libs/libmyodbc3-3.51.01.so *.o
-L/usr/local/mysql/lib/
-L/usr/local/iodbc/lib
-liodbcinst -lmysqlclient -lz -lc
To build the thread-safe driver library:
shell>CC=/usr/bin/gcc \
$CC -bundle -flat_namespace -undefined error
-o .libs/libmyodbc3-3.51.01.so *.o
-L/usr/local/mysql/lib/
-L/usr/local/iodbc/lib
-liodbcinst -lmysqlclienti_r -lz -lc -lpthread
Make sure to change the -liodbcinst
to
-lodbcinst
in case of using
unixODBC
instead of
iODBC
and configure the libraries path
accordingly.
In Apple's version of GCC, both cc and gcc are actually symbolic links to gcc3.
Copy this library to the $prefix/lib
directory and symlink to libmyodbc3.so
.
You can cross-check the output shared-library properties using this command:
shell> otool -LD .libs/libmyodbc3-3.51.01.so
To build the driver on HP-UX 10.x or 11.x, make use of the following configure example:
If using cc:
shell>CC="cc" \
CFLAGS="+z" \
LDFLAGS="-Wl,+b:-Wl,+s" \
./configure --prefix=/usr/local
--with-unixodbc=/usr/local
--with-mysql-path=/usr/local/mysql/lib/mysql
--enable-shared
--enable-thread-safe
If using gcc:
shell>CC="gcc" \
LDFLAGS="-Wl,+b:-Wl,+s" \
./configure --prefix=/usr/local
--with-unixodbc=/usr/local
--with-mysql-path=/usr/local/mysql
--enable-shared
--enable-thread-safe
Once the driver is built, cross-check its attributes using
chatr .libs/libmyodbc3.sl to determine
whether you need to have set the MySQL client library path
using the SHLIB_PATH
environment variable.
For static versions, ignore all shared-library options and run
configure with the
--disable-shared
option.
To build the driver on AIX, make use of the following configure example:
shell>./configure --prefix=/usr/local
--with-unixodbc=/usr/local
--with-mysql-path=/usr/local/mysql
--disable-shared
--enable-thread-safe
For more information about how to build and set up the static and shared libraries across the different platforms refer to ' Using static and shared libraries across platforms'.
User Comments
Add your own comment.