Building MariaDB Connector/C from the Source Code
Obtaining the Source Code
You can download a tar file containing the source code from the MariaDB Developers site. Select the source code package from the drop down list.
The source code for development releases of the connector can be found at http://launchpad.net/libmysql on the Launchpad site.
The source code for the 1.0 branch is also available on the Launchpad site.
To get the code, you must have Bazaar installed. Use the command bzr branch lp:libmysql
.
- Building on Unix
Examples of supported Unix or Unix-like operating systems include:
- Solaris
- Linux
- HP-UX
- AIX
- OS X
Compiler Tools
Ideally, the native compiler tool set for the target platform is used for compilation. This would be SunStudio for Solaris and aCC for HP-UX for example. However, the GNU tool-chain can be used across all platforms.
You also need CMake 2.6 or newer, which is available online.
To Build
If using GNU AutoTools, change to the MariaDB Connector/C source directory and follow the procedure below.
- To generate the makefile, enter:
shell> cmake -G 'Unix Makefiles'
or for a Debug build, enter:
shell> cmake -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE=Debug
- Then build the project using:
shell> make
To Install
By default,
make install
installs the MariaDB Connector/C files in the/usr/local
directory. To change this location, specify another directory when generating themakefile
:shell> cmake -G 'Unix Makefiles' -DCMAKE_INSTALL_PREFIX=/mypath
Now, in the root shell, enter the following to install the MariaDB Connector/C libraries and tools:
root-shell> make install
At this point, all of the MariaDB Connector/C files will be in place.
- Building on Microsoft Windows
Older versions of Microsoft Windows are not supported. Supported versions are Windows 2000, Windows XP, Windows Vista, Windows Server 2003, or Windows Server 2008.
Compiler Tools
Microsoft Visual Studio 8 and 9 are recommended. The Express Edition of Visual Studio and other compilers might work, but are untested.
You also need CMake 2.6 or newer, available at http://www.cmake.org.
To Build
Set the environment variables for the Visual Studio toolchain. Visual Studio includes a batch file to set these for you, and installs a shortcut into the Start menu to open a command prompt with these variables set.
Build MariaDB Connector/C using the CMake command-line tool by entering the following from the source root directory in a command prompt window:
shell> cmake -G 'Visual Studio 9 2008'
This produces a project file that you can open with Visual Studio or build from the command line with either of:
shell> devenv.com libmysql.sln /build Release
shell> devenv.com libmysql.sln /build RelWithDebInfo
For other versions of Visual Studio or
nmake
based build, run the following command:shell> cmake --help
to check the supported generators.
To compile the Debug build, you must run set the CMake build type so the correct version of external libraries are used:
shell> cmake -G 'Visual Studio 8 2005' -DCMAKE_BUILD_TYPE=Debug
Followed by:
shell> devenv.com libmysql.sln /build Debug
To Install
To create a install package you can choose between two variants:
- Creating a Zip package
- Creating an MSI install package
- Zip package
To create a Zip package, run the
cpack
command from the root of your MariaDB Connector/C source directory. - MSI Install package
The required tools include Windows XML Installer toolset (WIX), which is available online.
To create the MSI install package change to the subdirectory
win
and generate themakefile
:shell> cmake -G 'NMake Makefiles'
Create the MSI install package by calling
nmake
:shell> nmake
Build Options
The following options can be used when building the MariaDB Connector/C source code: