155
150
The binary will be installed in /usr/sbin/mysql-proxy, the example lua scripts
156
151
are placed into /usr/share/doc/packages/mysql-proxy
161
Visual C++ 2008 Express - http://www.microsoft.com/express/vc/ (free download, but needs free registration to use for more than 30 days)
162
bzr (if using Launchpad) - http://bazaar-vcs.org/Download
163
MySQL Server (>5.0) - http://dev.mysql.com/downloads/ (5.1 recommended)
164
7-Zip - http://www.7-zip.org/ (to open tar.gz files)
165
CMake (2.6) - http://www.cmake.org/files/v2.6/cmake-2.6.4-win32-x86.exe
166
GLib2 (>=2.16) - http://www.gtk.org/download-windows.html you need both the "bin" and "dev" binary packages
167
libevent (1.4.11) - source only: http://monkey.org/~provos/libevent/ (you need the exact version!)
168
Lua (>=5.1.4) - source only: http://www.lua.org/download.html
169
Flex - binary only: http://gnuwin32.sourceforge.net/packages/flex.htm
171
Compiling MySQL Proxy on Windows is a bit more involved, mostly because it has some dependencies that are unusual for
172
native Windows and unlike on Linux, Windows does not have a package manager like rpm or apt.
173
We do not use cygwin to avoid forcing users to install a complete Cygwin environment, even though Cygwin would make
174
most of this straightforward.
175
However, for all dependencies we need, with the exception of libevent, there are binary packages with DLLs available.
176
Libevent must be compiled as a DLL, but MySQL Proxy comes with the patches and CMake files to transparently do so.
178
After downloading all the packages from above install both Visual C++ 2008 Express, bzr, 7-Zip, CMake and MySQL Server
179
as any other Windows application that comes with an installer.
180
Attention: For the MySQL Server be sure to also install the "Developer Components".
181
You only need to install the "C Include Files/Lib Files".
182
It helps if you make sure to let the installers add their respective programs to the PATH variable, this makes dealing
183
with them on the command line easier.
185
Next, choose a directory where you will build MySQL Proxy and extract the dependencies to. A short path without spaces
186
is preferred because it makes it easier to enter the paths when running CMake (this example will use c:\work).
188
If you have downloaded the source package of MySQL Proxy, extract it to c:\work. If you are using the latest sources from
189
Launchpad, you can use the Windows Explorer with the TortoiseBzr plugin to branch the sources to c:\work.
190
This example will assume the MySQL Proxy sources are in c:\work\mysql-proxy.
192
Extract Flex, the two GLib2 packages and Lua to c:\work.
193
Note: Some files in the "dev" and "bin" GLib2 packages are identical, simply let 7-Zip overwrite them. The two packages are
194
necessary because one contains the .lib files and the other contains the DLLs we need at runtime (they get copied into the
197
At this point your folder structure in c:\work should look like this (omitting the subdirectories for brevity):
204
Since the Windows binaries available for Lua 5.1 are using a different version of Microsoft's C runtime dlls, we need to compile
205
it ourselves. In order to make it work for MySQL Proxy, we need to add two compiler flags to the .bat file Lua provides for
206
compiling with Visual Studio.
207
In the file etc\luavs.bat, edit this line:
208
@set MYCOMPILE=cl /nologo /MD /O2 /W3 /c /D_CRT_SECURE_NO_DEPRECATE
210
@set MYCOMPILE=cl /nologo /MD /O2 /W3 /c /D_CRT_SECURE_NO_DEPRECATE /D_BIND_TO_CURRENT_MFC_VERSION=1 /D_BIND_TO_CURRENT_CRT_VERSION=1
212
Then go to the Lua source directory and run the .bat file:
216
The resulting src\lua51.dll is now linked to the correct runtime DLL and can be used with MySQL Proxy.
218
Note that we have not extracted libevent yet. Since we will be building libevent from source with our DLL patches applied,
219
we extract libevent into a subdirectory of the MySQL Proxy sources. Using 7-Zip extract the folder libevent-1.4.11-stable into:
220
c:\work\mysql-proxy\deps\
221
Attention: When extracting libevent be sure to extract the folder, not the .tar file inside the .tar.gz archive (when opening
222
libevent-1.4.11-stable.tar.gz 7-Zip will only follow the .gz part, double click on the libevent-1.4.11-stable.tar inside 7-Zip
223
to be able to extract the folder, not the .tar archive!)
224
At this point c:\work\mysql-proxy\deps\libevent-1.4.11-stable should be a folder containing source files.
226
In a command line window, cd to c:\work\mysql-proxy.
227
We recommend performing an out-of-source build, i.e. executing CMake from a different directory than were the sources are,
228
because that makes it easy to throw away everything that was not part of the source archive - invaluable when fixing with build errors.
230
Create a directory called "build":
234
Inside the directory c:\work\mysql-proxy\build execute the following CMake command line (you may have to enable word wrapping in the program
235
you use to read this since it's all on one line to avoid problems with copy/pasting the command):
237
cmake -G "Visual Studio 9 2008" -DFLEX_EXECUTABLE=c:\work\flex\bin\flex -DMYSQL_INCLUDE_DIRS="c:\Program Files\MySQL\MySQL Server 5.1\include" -DGLIB_DEV_BASE_DIR=c:\work\glib -DLUA_INCLUDE_DIRS=c:\work\lua-5.1.4\src -DLUA_LIBRARY_DIRS=c:\work\lua-5.1.4\src -DCMAKE_INSTALL_PREFIX=c:\work\install -DCMAKE_BUILD_TYPE=Release ..
239
This command should end with a line like this:
241
Now we can actually compile MySQL Proxy:
242
You can either open the Visual C++ IDE and open the mysql-proxy.sln Solution file in c:\work\mysql-proxy\build and build the solution, or
243
use the vcbuild command from the command line. Both do the same thing.
244
If you want to use the binaries on a different machine than where you compiled them on, be sure to build using the "Release" configuration!
245
In the IDE there is a dropdown that let's you select it, or from the command line do:
246
cd c:\work\mysql-proxy\build
247
vcbuild mysql-proxy.sln "Release|Win32"
248
At this point, there will be lots of warnings during the compilation, but you can safely ignore them. However there should be no errors.
250
The build should end in a line like:
251
Build complete: 88 Projects succeeded, 0 Projects failed, 28 Projects skipped
253
You cannot easily run MySQL Proxy from its build directory, because it will not find the necessary DLLs. To produce a ZIP file you can use
254
to "install" MySQL Proxy use CPack (part of CMake):
257
(Note: CPack also supports NSIS installers, so if you have NSIS installed you can use cpack -G NSIS)
258
It will produce a ZIP file named like "mysql-proxy-0.7.2-win32.zip" in the directory c:\work\mysql-proxy\build.
259
Simply extract this ZIP file to whereever you want to install MySQL Proxy. Inside the new directory there will be the familiar
260
bin\mysql-proxy.exe command.
261
Verify that it works by running:
262
bin\mysql-proxy --help-all
264
Whew that's it, we are done :)
266
154
All other Platforms
267
155
-------------------