| 1 |
2.4.14.6 Installing MySQL from Source on Windows |
| 2 |
................................................ |
| 3 |
|
| 4 |
* Menu: |
| 5 |
|
| 6 |
* windows-source-build-cmake:: Building MySQL from Source Using CMake and Visual Studio |
| 7 |
* windows-vc-plus-plus-build:: Building MySQL from Source Using VC++ |
| 8 |
* borland-c-plus-plus:: Building MySQL from Source Using Borland C++ |
| 9 |
* windows-bitkeeper-build:: Creating a Windows Source Package from the Latest Development Source |
| 10 |
|
| 11 |
This section does not apply to MySQL Enterprise Server users. |
| 12 |
|
| 13 |
These instructions describe how to build binaries from source for MySQL |
| 14 |
5.0 on Windows. Instructions are provided for building binaries from a |
| 15 |
standard source distribution or from the BitKeeper tree that contains |
| 16 |
the latest development source. |
| 17 |
|
| 18 |
*Note*: The instructions here are strictly for users who want to test |
| 19 |
MySQL on Microsoft Windows from the latest source distribution or from |
| 20 |
the BitKeeper tree. For production use, MySQL AB does not advise using |
| 21 |
a MySQL server built by yourself from source. Normally, it is best to |
| 22 |
use precompiled binary distributions of MySQL that are built |
| 23 |
specifically for optimal performance on Windows by MySQL AB. |
| 24 |
Instructions for installing binary distributions are available in *Note |
| 25 |
windows-installation::. |
| 26 |
|
| 27 |
To build MySQL on Windows from source, you must satisfy the following |
| 28 |
system, compiler, and resource requirements: |
| 29 |
|
| 30 |
* Windows 2000, Windows XP, or newer version. Windows Vista is not |
| 31 |
supported until Microsoft certifies Visual Studio 2005 on Vista. |
| 32 |
|
| 33 |
* CMake, which can be downloaded from `http://www.cmake.org'. After |
| 34 |
installing, modify your path to include the `cmake' binary. |
| 35 |
|
| 36 |
* Microsoft Visual C++ 2005 Express Edition, Visual Studio .Net 2003 |
| 37 |
(7.1), or Visual Studio 2005 (8.0) compiler system. |
| 38 |
|
| 39 |
* If you are using Visual C++ 2005 Express Edition, you must also |
| 40 |
install an appropriate Platform SDK. More information and links to |
| 41 |
downloads for various Windows platforms is available from |
| 42 |
`http://msdn.microsoft.com/platformsdk/'. |
| 43 |
|
| 44 |
* If you are compiling from a BitKeeper tree or making changes to |
| 45 |
the parser, you need `bison' for Windows, which can be downloaded |
| 46 |
from `http://gnuwin32.sourceforge.net/packages/bison.htm'. |
| 47 |
Download the package labeled `Complete package, excluding |
| 48 |
sources'. After installing the package, modify your path to |
| 49 |
include the `bison' binary and ensure that this binary is |
| 50 |
accessible from Visual Studio. |
| 51 |
|
| 52 |
* Cygwin might be necessary if you want to run the test script or |
| 53 |
package the compiled binaries and support files into a Zip |
| 54 |
archive. (Cygwin is needed only to test or package the |
| 55 |
distribution, not to build it.) Cygwin is available from |
| 56 |
`http://cygwin.com'. |
| 57 |
|
| 58 |
* 3GB to 5GB of disk space. |
| 59 |
|
| 60 |
The exact system requirements can be found here: |
| 61 |
`http://msdn.microsoft.com/vstudio/Previous/2003/sysreqs/default.aspx' |
| 62 |
and `http://msdn.microsoft.com/vstudio/products/sysreqs/default.aspx' |
| 63 |
|
| 64 |
You also need a MySQL source distribution for Windows, which can be |
| 65 |
obtained two ways: |
| 66 |
|
| 67 |
* Obtain a Windows source distribution packaged by MySQL AB for the |
| 68 |
particular version of MySQL in which you are interested. These are |
| 69 |
available from `http://dev.mysql.com/downloads/'. |
| 70 |
|
| 71 |
* Package a source distribution yourself from the latest BitKeeper |
| 72 |
developer source tree. If you plan to do this, and you are not |
| 73 |
using the CMake build method, you must create the package on a |
| 74 |
Unix system and then transfer it to your Windows system. (Some of |
| 75 |
the configuration and build steps require tools that work only on |
| 76 |
Unix.) Thus, if you are not using CMake, the BitKeeper approach |
| 77 |
requires: |
| 78 |
|
| 79 |
* A system running Unix, or a Unix-like system such as Linux. |
| 80 |
|
| 81 |
* BitKeeper installed on that system. See *Note |
| 82 |
installing-source-tree::, for instructions how to download |
| 83 |
and install BitKeeper. |
| 84 |
|
| 85 |
If you are using a Windows source distribution, you can go directly to |
| 86 |
*Note windows-source-build-cmake::, or *Note |
| 87 |
windows-vc-plus-plus-build::. To build from the BitKeeper tree without |
| 88 |
CMake, proceed to *Note windows-bitkeeper-build::. |
| 89 |
|
| 90 |
If you find something not working as expected, or you have suggestions |
| 91 |
about ways to improve the current build process on Windows, please send |
| 92 |
a message to the `win32' mailing list. See *Note mailing-lists::. |
| 93 |
|
| 94 |
File: manual.info, Node: windows-source-build-cmake, Next: windows-vc-plus-plus-build, Prev: windows-source-build, Up: windows-source-build |
| 95 |
|
| 96 |
2.4.14.7 Building MySQL from Source Using CMake and Visual Studio |
| 97 |
................................................................. |
| 98 |
|
| 99 |
This section does not apply to MySQL Enterprise Server users. |
| 100 |
|
| 101 |
Follow this procedure to build MySQL: |
| 102 |
|
| 103 |
1. If you are installing from a packaged source distribution, create |
| 104 |
a work directory (for example, `C:\workdir'), and unpack the source |
| 105 |
distribution there using `WinZip' or another Windows tool that can |
| 106 |
read `.zip' files. This directory is the work directory in the |
| 107 |
following instructions. |
| 108 |
|
| 109 |
2. If you are installing from a BitKeeper tree, the root directory of |
| 110 |
that tree is the work directory in the following instructions. |
| 111 |
|
| 112 |
3. Using a command shell, navigate to the work directory and run the |
| 113 |
following command: |
| 114 |
|
| 115 |
C:\workdir>win\configure OPTIONS |
| 116 |
|
| 117 |
These options are available: |
| 118 |
|
| 119 |
* `WITH_INNOBASE_STORAGE_ENGINE': Enable the `InnoDB' storage |
| 120 |
engine. |
| 121 |
|
| 122 |
* `WITH_PARTITION_STORAGE_ENGINE': Enable user-defined |
| 123 |
partitioning. |
| 124 |
|
| 125 |
* `WITH_ARCHIVE_STORAGE_ENGINE': Enable the `ARCHIVE' storage |
| 126 |
engine. |
| 127 |
|
| 128 |
* `WITH_BLACKHOLE_STORAGE_ENGINE': Enable the `BLACKHOLE' |
| 129 |
storage engine. |
| 130 |
|
| 131 |
* `WITH_EXAMPLE_STORAGE_ENGINE': Enable the `EXAMPLE' storage |
| 132 |
engine. |
| 133 |
|
| 134 |
* `WITH_FEDERATED_STORAGE_ENGINE': Enable the `FEDERATED' |
| 135 |
storage engine. |
| 136 |
|
| 137 |
* `__NT__': Enable support for named pipes. |
| 138 |
|
| 139 |
* `MYSQL_SERVER_SUFFIX=SUFFIX': Server suffix, default none. |
| 140 |
|
| 141 |
* `COMPILATION_COMMENT=COMMENT': Server comment, default |
| 142 |
"Source distribution". |
| 143 |
|
| 144 |
* `MYSQL_TCP_PORT=PORT': Server port, default 3306. |
| 145 |
|
| 146 |
* `DISABLE_GRANT_OPTIONS': Disables the the `--bootstrap', |
| 147 |
`--skip-grant-tables', and `--init-file' options for |
| 148 |
`mysqld'. This option is available as of MySQL 5.0.36. |
| 149 |
|
| 150 |
For example (type the command on one line): |
| 151 |
|
| 152 |
C:\workdir>win\configure WITH_INNOBASE_STORAGE_ENGINE |
| 153 |
WITH_PARTITION_STORAGE_ENGINE MYSQL_SERVER_SUFFIX=-pro |
| 154 |
|
| 155 |
4. From the work directory, execute the `win\build-vs8.bat' or |
| 156 |
`win\build-vs71.bat' file, depending on the version of Visual |
| 157 |
Studio you have installed. The script invokes CMake, which |
| 158 |
generates the `mysql.sln' solution file. |
| 159 |
|
| 160 |
You can also use `win\build-vs8_x64.bat' to build the 64-bit |
| 161 |
version of MySQL. However, you cannot build the 64-bit version |
| 162 |
with Visual Studio Express Edition. You must use Visual Studio |
| 163 |
2005 (8.0) or higher. |
| 164 |
|
| 165 |
5. From the work directory, open the generated `mysql.sln' file with |
| 166 |
Visual Studio and select the proper configuration using the |
| 167 |
`Configuration' menu. The menu provides `Debug', `Release', |
| 168 |
`RelwithDebInfo', `MinRelInfo' options. Then select `Solution' > |
| 169 |
`Build' to build the solution. |
| 170 |
|
| 171 |
Remember the configuration that you use in this step. It is |
| 172 |
important later when you run the test script because that script |
| 173 |
needs to know which configuration you used. |
| 174 |
|
| 175 |
6. Test the server. The server built using the preceding instructions |
| 176 |
expects that the MySQL base directory and data directory are |
| 177 |
`C:\mysql' and `C:\mysql\data' by default. If you want to test |
| 178 |
your server using the source tree root directory and its data |
| 179 |
directory as the base directory and data directory, you need to |
| 180 |
tell the server their pathnames. You can either do this on the |
| 181 |
command line with the `--basedir' and `--datadir' options, or by |
| 182 |
placing appropriate options in an option file. (See *Note |
| 183 |
option-files::.) If you have an existing data directory elsewhere |
| 184 |
that you want to use, you can specify its pathname instead. |
| 185 |
|
| 186 |
When the server is running in standalone fashion or as a service |
| 187 |
based on your configuration, try to connect to it from the `mysql' |
| 188 |
interactive command-line utility. |
| 189 |
|
| 190 |
You can also run the standard test script, `mysql-test-run.pl'. |
| 191 |
This script is written in Perl, so you'll need either Cygwin or |
| 192 |
ActiveState Perl to run it. You may also need to install the |
| 193 |
modules required by the script. To run the test script, change |
| 194 |
location into the `mysql-test' directory under the work directory, |
| 195 |
set the `MTR_VS_CONFIG' environment variable to the configuration |
| 196 |
you selected earlier (or use the `--vs-config' option), and invoke |
| 197 |
`mysql-test-run.pl'. For example (using Cygwin and the `bash' |
| 198 |
shell): |
| 199 |
|
| 200 |
shell> `cd mysql-test' |
| 201 |
shell> `export MTS_VS_CONFIG=debug' |
| 202 |
shell> `./mysqltest-run.pl --force --timer' |
| 203 |
shell> `./mysqltest-run.pl --force --timer --ps-protocol' |
| 204 |
|
| 205 |
When you are satisfied that the programs you have built are working |
| 206 |
correctly, stop the server. Now you can install the distribution. One |
| 207 |
way to do this is to use the `make_win_bin_dist' script in the |
| 208 |
`scripts' directory of the MySQL source distribution (see *Note |
| 209 |
make-win-bin-dist::). This is a shell script, so you must have Cygwin |
| 210 |
installed if you want to use it. It creates a Zip archive of the built |
| 211 |
executables and support files that you can unpack in the location at |
| 212 |
which you want to install MySQL. |
| 213 |
|
| 214 |
It is also possible to install MySQL by copying directories and files |
| 215 |
directly: |
| 216 |
|
| 217 |
1. Create the directories where you want to install MySQL. For |
| 218 |
example, to install into `C:\mysql', use these commands: |
| 219 |
|
| 220 |
C:\> mkdir C:\mysql |
| 221 |
C:\> mkdir C:\mysql\bin |
| 222 |
C:\> mkdir C:\mysql\data |
| 223 |
C:\> mkdir C:\mysql\share |
| 224 |
C:\> mkdir C:\mysql\scripts |
| 225 |
|
| 226 |
If you want to compile other clients and link them to MySQL, you |
| 227 |
should also create several additional directories: |
| 228 |
|
| 229 |
C:\> mkdir C:\mysql\include |
| 230 |
C:\> mkdir C:\mysql\lib |
| 231 |
C:\> mkdir C:\mysql\lib\debug |
| 232 |
C:\> mkdir C:\mysql\lib\opt |
| 233 |
|
| 234 |
If you want to benchmark MySQL, create this directory: |
| 235 |
|
| 236 |
C:\> mkdir C:\mysql\sql-bench |
| 237 |
|
| 238 |
Benchmarking requires Perl support. See *Note perl-support::. |
| 239 |
|
| 240 |
2. From the work directory, copy into the `C:\mysql' directory the |
| 241 |
following directories: |
| 242 |
|
| 243 |
C:\> cd \workdir |
| 244 |
C:\workdir> copy client_release\*.exe C:\mysql\bin |
| 245 |
C:\workdir> copy client_debug\mysqld.exe C:\mysql\bin\mysqld-debug.exe |
| 246 |
C:\workdir> xcopy scripts\*.* C:\mysql\scripts /E |
| 247 |
C:\workdir> xcopy share\*.* C:\mysql\share /E |
| 248 |
|
| 249 |
If you want to compile other clients and link them to MySQL, you |
| 250 |
should also copy several libraries and header files: |
| 251 |
|
| 252 |
C:\workdir> copy lib_debug\mysqlclient.lib C:\mysql\lib\debug |
| 253 |
C:\workdir> copy lib_debug\libmysql.* C:\mysql\lib\debug |
| 254 |
C:\workdir> copy lib_debug\zlib.* C:\mysql\lib\debug |
| 255 |
C:\workdir> copy lib_release\mysqlclient.lib C:\mysql\lib\opt |
| 256 |
C:\workdir> copy lib_release\libmysql.* C:\mysql\lib\opt |
| 257 |
C:\workdir> copy lib_release\zlib.* C:\mysql\lib\opt |
| 258 |
C:\workdir> copy include\*.h C:\mysql\include |
| 259 |
C:\workdir> copy libmysql\libmysql.def C:\mysql\include |
| 260 |
|
| 261 |
If you want to benchmark MySQL, you should also do this: |
| 262 |
|
| 263 |
C:\workdir> xcopy sql-bench\*.* C:\mysql\bench /E |
| 264 |
|
| 265 |
After installation, set up and start the server in the same way as for |
| 266 |
binary Windows distributions. See *Note windows-installation::. |
| 267 |
|
| 268 |
File: manual.info, Node: windows-vc-plus-plus-build, Next: borland-c-plus-plus, Prev: windows-source-build-cmake, Up: windows-source-build |
| 269 |
|
| 270 |
2.4.14.8 Building MySQL from Source Using VC++ |
| 271 |
.............................................. |
| 272 |
|
| 273 |
This section does not apply to MySQL Enterprise Server users. |
| 274 |
|
| 275 |
*Note*: VC++ workspace files for MySQL 4.1 and above are compatible |
| 276 |
with Microsoft Visual Studio 7.1 and tested by MySQL AB staff before |
| 277 |
each release. |
| 278 |
|
| 279 |
Follow this procedure to build MySQL: |
| 280 |
|
| 281 |
1. Create a work directory (for example, `C:\workdir'). |
| 282 |
|
| 283 |
2. Unpack the source distribution in the aforementioned directory |
| 284 |
using `WinZip' or another Windows tool that can read `.zip' files. |
| 285 |
|
| 286 |
3. Start Visual Studio .Net 2003 (7.1). |
| 287 |
|
| 288 |
4. From the `File' menu, select `Open Solution...'. |
| 289 |
|
| 290 |
5. Open the `mysql.sln' solution you find in the work directory. |
| 291 |
|
| 292 |
6. From the `Build' menu, select `Configuration Manager...'. |
| 293 |
|
| 294 |
7. In the `Active Solution Configuration' pop-up menu, select the |
| 295 |
configuration to use. You likely want to use one of `nt' (normal |
| 296 |
server), `Max nt' (more engines and features), or `Debug' |
| 297 |
configuration. |
| 298 |
|
| 299 |
8. From the `Build' menu, select `Build Solution'. |
| 300 |
|
| 301 |
9. Debug versions of the programs and libraries are placed in the |
| 302 |
`client_debug' and `lib_debug' directories. Release versions of |
| 303 |
the programs and libraries are placed in the `client_release' and |
| 304 |
`lib_release' directories. |
| 305 |
|
| 306 |
10. Test the server. The server built using the preceding instructions |
| 307 |
expects that the MySQL base directory and data directory are |
| 308 |
`C:\mysql' and `C:\mysql\data' by default. If you want to test |
| 309 |
your server using the source tree root directory and its data |
| 310 |
directory as the base directory and data directory, you need to |
| 311 |
tell the server their pathnames. You can either do this on the |
| 312 |
command line with the `--basedir' and `--datadir' options, or by |
| 313 |
placing appropriate options in an option file. (See *Note |
| 314 |
option-files::.) If you have an existing data directory elsewhere |
| 315 |
that you want to use, you can specify its pathname instead. |
| 316 |
|
| 317 |
11. Start your server from the `client_release' or `client_debug' |
| 318 |
directory, depending on which server you built or want to use. The |
| 319 |
general server startup instructions are in *Note |
| 320 |
windows-installation::. You must adapt the instructions |
| 321 |
appropriately if you want to use a different base directory or |
| 322 |
data directory. |
| 323 |
|
| 324 |
12. When the server is running in standalone fashion or as a service |
| 325 |
based on your configuration, try to connect to it from the `mysql' |
| 326 |
interactive command-line utility that exists in your |
| 327 |
`client_release' or `client_debug' directory. |
| 328 |
|
| 329 |
When you are satisfied that the programs you have built are working |
| 330 |
correctly, stop the server. Then install MySQL using the instructions |
| 331 |
at the end of *Note windows-source-build-cmake::. |
| 332 |
|
| 333 |
After installation, set up and start the server in the same way as for |
| 334 |
binary Windows distributions. See *Note windows-installation::. |
| 335 |
|
| 336 |
File: manual.info, Node: borland-c-plus-plus, Next: windows-bitkeeper-build, Prev: windows-vc-plus-plus-build, Up: windows-source-build |
| 337 |
|
| 338 |
2.4.14.9 Building MySQL from Source Using Borland C++ |
| 339 |
..................................................... |
| 340 |
|
| 341 |
This section does not apply to MySQL Enterprise Server users. |
| 342 |
|
| 343 |
You can compile the MySQL Windows source with Borland C++ 5.02. (The |
| 344 |
Windows source includes only projects for Microsoft VC++, for Borland |
| 345 |
C++ you have to do the project files yourself.) |
| 346 |
|
| 347 |
One known problem with Borland C++ is that it uses a different |
| 348 |
structure alignment than VC++. This means that you run into problems if |
| 349 |
you try to use the default `libmysql.dll' libraries (that were compiled |
| 350 |
using VC++) with Borland C++. To avoid this problem, only call |
| 351 |
`mysql_init()' with `NULL' as an argument, not a pre-allocated `MYSQL' |
| 352 |
structure. |
| 353 |
|
| 354 |
File: manual.info, Node: windows-bitkeeper-build, Prev: borland-c-plus-plus, Up: windows-source-build |
| 355 |
|
| 356 |
2.4.14.10 Creating a Windows Source Package from the Latest Development Source |
| 357 |
.............................................................................. |
| 358 |
|
| 359 |
This section does not apply to MySQL Enterprise Server users. |
| 360 |
|
| 361 |
To create a Windows source package from the current BitKeeper source |
| 362 |
tree, use the instructions here. This procedure must be performed on a |
| 363 |
system running a Unix or Unix-like operating system because some of the |
| 364 |
configuration and build steps require tools that work only on Unix. For |
| 365 |
example, the following procedure is known to work well on Linux. |
| 366 |
|
| 367 |
1. Copy the BitKeeper source tree for MySQL 5.0. For instructions on |
| 368 |
how to do this, see *Note installing-source-tree::. |
| 369 |
|
| 370 |
2. Configure and build the distribution so that you have a server |
| 371 |
binary to work with. One way to do this is to run the following |
| 372 |
command in the top-level directory of your source tree: |
| 373 |
|
| 374 |
shell> ./BUILD/compile-pentium-max |
| 375 |
|
| 376 |
3. After making sure that the build process completed successfully, |
| 377 |
run the following utility script from top-level directory of your |
| 378 |
source tree: |
| 379 |
|
| 380 |
shell> ./scripts/make_win_src_distribution |
| 381 |
|
| 382 |
This script creates a Windows source package to be used on your |
| 383 |
Windows system. You can supply different options to the script |
| 384 |
based on your needs. See *Note make-win-src-distribution::, for a |
| 385 |
list of allowable options. |
| 386 |
|
| 387 |
By default, `make_win_src_distribution' creates a Zip-format |
| 388 |
archive with the name `mysql-VERSION-win-src.zip', where VERSION |
| 389 |
represents the version of your MySQL source tree. |
| 390 |
|
| 391 |
4. Copy or upload the Windows source package that you have just |
| 392 |
created to your Windows machine. To compile it, use the |
| 393 |
instructions in *Note windows-vc-plus-plus-build::. |
| 394 |
|
| 395 |
File: manual.info, Node: windows-client-compiling, Prev: windows-source-build, Up: installing-source |
| 396 |
|
| 397 |
2.4.14.11 Compiling MySQL Clients on Windows |
| 398 |
............................................ |
| 399 |
|
| 400 |
This section does not apply to MySQL Enterprise Server users. |
| 401 |
|
| 402 |
In your source files, you should include `my_global.h' before `mysql.h': |
| 403 |
|
| 404 |
#include <my_global.h> |
| 405 |
#include <mysql.h> |
| 406 |
|
| 407 |
`my_global.h' includes any other files needed for Windows compatibility |
| 408 |
(such as `windows.h') if you compile your program on Windows. |
| 409 |
|
| 410 |
You can either link your code with the dynamic `libmysql.lib' library, |
| 411 |
which is just a wrapper to load in `libmysql.dll' on demand, or link |
| 412 |
with the static `mysqlclient.lib' library. |
| 413 |
|
| 414 |
The MySQL client libraries are compiled as threaded libraries, so you |
| 415 |
should also compile your code to be multi-threaded. |
| 416 |
|