[+/-]
Installing Connector/ODBC from a source distribution gives you greater flexibility in the contents and installation location of the Connector/ODBC components. It also enables you to build and install Connector/ODBC on platforms where a pre-compiled binary is not available.
Connector/ODBC sources are available either as a downloadable package, or through the revision control system used by the Connector/ODBC developers.
[+/-]
You should only need to install Connector/ODBC from source on Windows if you want to change or modify the source or installation. If you are unsure whether to install from source, please use the binary installation detailed in Sección 25.1.2.3.1, “Installing Connector/ODBC from a Binary Distribution on Windows”.
Installing Connector/ODBC from source on Windows requires a number of different tools and packages:
MDAC, Microsoft Data Access SDK from http://www.microsoft.com/data/.
Suitable C compiler, such as Microsoft Visual C++ or the C compiler included with Microsoft Visual Studio.
              Compatible make tool. Microsoft's
              nmake is used in the examples in this
              section.
            
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/.
            Connector/ODBC source distributions include
            Makefiles that require the
            nmake or other make
            utility. In the distribution, you can find
            Makefile for building the release
            version and Makefile_debug for building
            debugging versions of the driver libraries and DLLs.
          
To build the driver, use this procedure:
                Download and extract the sources to a folder, then
                change directory into that folder. The following command
                assumes the folder is named
                myodbc3-src:
              
C:\> cd myodbc3-src
                Edit Makefile to specify the
                correct path for the MySQL client libraries and header
                files. Then use the following commands to build and
                install the release version:
              
C:\>nmake -f MakefileC:\>nmake -f Makefile install
                nmake -f Makefile builds the release
                version of the driver and places the binaries in
                subdirectory called Release.
              
                nmake -f Makefile install installs
                (copies) the driver DLLs and libraries
                (myodbc3.dll,
                myodbc3.lib) to your system
                directory.
              
                To build the debug version, use
                Makefile_Debug rather than
                Makefile, as shown below:
              
C:\>nmake -f Makefile_debugC:\>nmake -f Makefile_debug install
You can clean and rebuild the driver by using:
C:\>nmake -f Makefile cleanC:\>nmake -f Makefile install
Note:
                Make sure to specify the correct MySQL client libraries
                and header files path in the Makefiles (set the
                MYSQL_LIB_PATH and
                MYSQL_INCLUDE_PATH variables). The
                default header file path is assumed to be
                C:\mysql\include. The default
                library path is assumed to be
                C:\mysql\lib\opt for release DLLs
                and C:\mysql\lib\debug for debug
                versions.
              
For the complete usage of nmake, visit http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vcce4/html/evgrfRunningNMAKE.asp.
                If you are using the Subversion tree for compiling, all
                Windows-specific Makefiles are
                named as Win_Makefile*.
              
            After the driver libraries are copied/installed to the
            system directory, you can test whether the libraries are
            properly built by using the samples provided in the
            samples subdirectory:
          
C:\>cd samplesC:\>nmake -f Makefile all
[+/-]
You need the following tools to build MySQL from source on Unix:
A working ANSI C++ compiler. gcc 2.95.2 or later, egcs 1.0.2 or later or egcs 2.91.66, 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
              Sección 25.1.1.2.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 Capítulo 10, Soporte de conjuntos de caracteres,
              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 DIRDIR 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 DIRDIR is the
                    directory where iODBC is
                    installed.
                  
                    If the iODBC headers do not
                    reside in
                    DIR/include--with-iodbc-includes=
                    option to specify their location.
                  INCDIR
                    The applies to libraries. If they are not in
                    DIR/lib--with-iodbc-libs=
                    option.
                  LIBDIR
                    If you are using unixODBC, use
                    the
                    --with-unixODBC=
                    option (case sensitive) to make
                    configure look for
                    DIRunixODBC instead of
                    iODBC by default,
                    DIR is the directory
                    where unixODBC is installed.
                  
                    If the unixODBC headers and
                    libraries aren't located in
                    DIR/includeDIR/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
                non-debugging 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.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).
          
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.socatalog.o connect.o cursor.o dll.o error.o execute.ohandle.o info.o misc.o myodbc3.o options.o prepare.oresults.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 MyODBC 2.5.0:
                libmyodbc.so
              
                libmyodbc-2.50.39.so, where 2.50.39
                is the version of the driver
              
                libmyodbc.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>makeshell>cd drivershell>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
NOTE: 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'.
Caution: You should read this section only if you are interested in helping us test our new code. If you just want to get MySQL Connector/ODBC up and running on your system, you should use a standard release distribution.
To be able to access the Connector/ODBC source tree, you must have Subversion installed. Subversion is freely available from http://subversion.tigris.org/.
To build from the source trees, you need the following tools:
autoconf 2.52 (or newer)
automake 1.4 (or newer)
libtool 1.4 (or newer)
m4
The most recent development source tree is available from our public Subversion trees at http://dev.mysql.com/tech-resources/sources.html.
To checkout out the Connector/ODBC sources, change to the directory where you want the copy of the Connector/ODBC tree to be stored, then use the following command:
shell> svn co http://svn.mysql.com/svnpublic/connector-odbc3
          You should now have a copy of the entire Connector/ODBC source
          tree in the directory connector-odbc3. To
          build from this source tree on Unix or Linux follow these
          steps:
        
shell>cd connector-odbc3shell>aclocalshell>autoheadershell>autoconfshell>automake;shell>./configure # Add your favorite options hereshell>make
          For more information on how to build, refer to the
          INSTALL file located in the same
          directory. For more information on options to
          configure, see
          Sección 25.1.2.4.2.1, “Typical configure Options”
        
When the build is done, run make install to install the Connector/ODBC 3.51 driver on your system.
          If you have gotten to the make stage and
          the distribution does not compile, please report it to
          <myodbc@lists.mysql.com>.
        
          On Windows, make use of Windows Makefiles
          WIN-Makefile and
          WIN-Makefile_debug in building the
          driver. For more information, see
          Sección 25.1.2.4.1, “Installing Connector/ODBC from a Source Distribution on Windows”.
        
After the initial checkout operation to get the source tree, you should run svn update periodically update your source according to the latest version.
Ésta es una traducción del manual de referencia de MySQL, que puede encontrarse en dev.mysql.com. El manual de referencia original de MySQL está escrito en inglés, y esta traducción no necesariamente está tan actualizada como la versión original. Para cualquier sugerencia sobre la traducción y para señalar errores de cualquier tipo, no dude en dirigirse a mysql-es@vespito.com.

