Categories: Contributing | Development | MySQLUniversity

Building MySQL on Windows


Contents


← Back to MySQL University main page

[edit] Building MySQL on Windows

[edit] Presentation

[edit] Building MySQL on Windows

This presentation will demonstrate how I setup an environment for building MySQL on Windows. While not strictly necessary, installing and running the Windows build system in a virtual machine allows for a single source repository to be shared among multiple flavors of Windows and/or other operating systems. We will focus on using only free or open source tools in the build environment, specifically we'll be using: VMWare Server, Microsoft Visual Studio Express 2005, Microsoft Windows Platform SDK, KitWare CMake, GNUWin32 Bison and Red Hat CygWin.

[edit] Configure the machine

[edit] Obtain MySQL Source
[edit] Install build tools

[edit] Build the Source

[edit] Configure CMake
  function win_con() {
     cscript win/configure.js WITH_INNOBASE_STORAGE_ENGINE WITH_PARTITION_STORAGE_ENGINE WITH_ARCHIVE_STORAGE_ENGINE WITH_BLACKHOLE_STORAGE_ENGINE WITH_EXAMPLE_STORAGE_ENGINE WITH_FEDERATED_STORAGE_ENGINE __NT__
  }
[edit] Example
$ win_con
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
 
done!
[edit] Changing build option
[edit] Create the Visual Studio Solution
  1. For VS2003 use win/build_vs71.bat
  2. For VS2005 use win/build_vs8.bat
  3. For VS2005 x64 use win/build_vs8_x64.bat
[edit] Example
$ win/build-vs8.bat
The system cannot find the file specified.
-- Check for working C compiler: cl
-- Check for working C compiler: cl -- works
-- Check size of void*
-- Check size of void* - done
-- Check for working CXX compiler: cl
-- Check for working CXX compiler: cl -- works
-- Configuring done
-- Generating done
-- Build files have been written to: r:/mysql-5.1-maint_win
       1 file(s) copied.
[edit] Build the Solution

At this point, CMake has created the solution and all the project files necessary to build MySQL.

  1. Click Start -> Programs -> Visual Studio C++ Express Edition -> Microsoft Visual C++ 2005 Express Edition so start the IDE.
  2. Open the solution created by CMake. Click File -> Open -> Project/Soution (CTRL+SHIFT+O) and then browsing for the file MySQL.sln in the source root.
  3. Choose the configuration from the center drop down Image:Config_Selector.jpg
  4. Click Build -> Build Solutin (F7) to start the build.

[edit] Use the Results

[edit] Running the Testsuite

The Microsoft IDE allows you to build different configurations of the source in the same build tree. This can be especially useful for mix-match release/debug client/server testing. mysql-test-run(mtr) will try to guess which configuration you want to test but it's best to be specific. mtr provides the --vs-config dir option to allow you to which configuration it should test. You can either specify the configuration name as a parameter to mtr on the command line(ie --vs-config=release) or by setting the MTR_VS_CONFIG environment variable (ie EXPORT MTR_VS_CONFIG=release).

[edit] Example
export MTR_BUILD_THREAD=51
export MTR_VS_CONFIG=release
cd mysql-test
./mysql-test-run.pl --force --timer
[edit] Debugging

Debugging MySQL in the Visual Studio IDE can be a bit awkward but it's well worth the effort. If you haven't already now's the time to build the solution's Debug configuration. The following example is presented to illustrate a technique for basic debugging.

[edit] Example
  1. Start the mtr script
export MTR_VS_CONFIG=debug
cd mysql-test
$./mysql-test-run.pl --manual-debug alter_table
Logging: ./mysql-test-run.pl --manual-debug alter_table
070801 16:12:20 [Note] z:\mysql-5.1-maint_win\sql\debug\mysqld.exe: Shutdown complete

MySQL Version 5.1.21
Using binlog format 'mixed'
Disable Instance manager - testing not supported on Windows
Skipping ndbcluster, mysqld not compiled with ndbcluster
Setting mysqld to support SSL connections
Using MTR_BUILD_THREAD      = 51
Using MASTER_MYPORT         = 10510
Using MASTER_MYPORT1        = 10511
Using SLAVE_MYPORT          = 10512
Using SLAVE_MYPORT1         = 10513
Using SLAVE_MYPORT2         = 10514
Killing Possible Leftover Processes
Removing Stale Files
Creating Directories
Installing Master Database
Installing Master Database
=======================================================

TEST                           RESULT         TIME (ms)
-------------------------------------------------------


Start master in your debugger
dir: z:/mysql-5.1-maint_win/mysql-test
exe: z:/mysql-5.1-maint_win/sql/debug/mysqld.exe
args:  --no-defaults --basedir=z:/mysql-5.1-maint_win/mysql-test --character-sets-dir=z:/mysql-5.1-maint_win/sql/share/charsets --secure-file-priv=z:/mysql-5.1-maint_win/mysql-test/var --log-bin-trust-function-creators --default-character-set=latin1 --language=z:/mysql-5.1-maint_win/sql/share/english --tmpdir=z:/mysql-5.1-maint_win/mysql-test/var/tmp --pid-file=z:/mysql-5.1-maint_win/mysql-test/var/run/master.pid --port=10510 --socket=z:/mysql-5.1-maint_win/mysql-test/var/tmp/master.sock --datadir=z:/mysql-5.1-maint_win/mysql-test/var/master-data --log-output=table,file --log=z:/mysql-5.1-maint_win/mysql-test/var/log/master.log --log-slow-queries=z:/mysql-5.1-maint_win/mysql-test/var/log/master-slow.log --server-id=1 --loose-innodb_data_file_path=ibdata1:10M:autoextend --local-infile --loose-skip-innodb --loose-skip-ndbcluster --key_buffer_size=1M --sort_buffer=256K --max_heap_table_size=1M --ssl-ca=z:/mysql-5.1-maint_win/mysql-test/std_data/cacert.pem --ssl-cert=z:/mysql-5.1-maint_win/mysql-test/std_data/server-cert.pem --ssl-key=z:/mysql-5.1-maint_win/mysql-test/std_data/server-key.pem --gdb --skip-log-bin --core-file --open-files-limit=1024

Waiting ....
  1. Switch to the IDE and make sure the Debug configuration is selected.
  2. Set mysqld as the StartUp Project. Click mysqld in the Solution Explorer then click Project -> Set as StartUp Project.
  3. Open the mysqld Debugging Properties. Click Project -> Properties -> Debugging Image:Debug_Properties.jpg
  4. Set the Command Arguments and Working Directory output by mtr then click Apply -> OK
  5. Start the server in the debugger. Click Debug -> Start Debugging (F7)
  6. Set breakpoints. Optional.
  7. Switch to the CygWin window to see the results
Waiting ....
main.alter_table               [ pass ]           7960
-------------------------------------------------------
All 1 tests were successful.
The servers were restarted 1 times
Spent 7.96 seconds actually executing testcases

[edit] Questions

[edit] Questions asked before the session

  1. FIRST_QUESTION
    • FIRST_ANSWER
  2. SECOND_QUESTION
    • SECOND_ANSWER
  3. ...
    • ...

[edit] Questions asked during the session

  1. FIRST_QUESTION
    • FIRST_ANSWER
  2. SECOND_QUESTION
    • SECOND_ANSWER
  3. ...
    • ...

[edit] Voice recording and other links

Retrieved from "http://forge.mysql.com/wiki/Building_MySQL_on_Windows"

This page has been accessed 3,087 times. This page was last modified 13:11, 6 August 2008.

Find

Browse
MySQLForge
Main Page
Current events
Recent changes
Random page
Help
Edit
Edit this page
Editing help
This page
Discuss this page
Post a comment
Printable version
Context
Page history
What links here
Related changes
My pages
Special pages
New pages
File list
Statistics
Bug reports
More...