Not counting obtaining the source code, and once you have the prerequisites satisfied, [Windows] users can build from source code in 5 easy steps.

Prerequisites – Install & ensure they are in the $PATH:

  1. CMake <-- Download
  2. C++ compiler <-- Visual Studio 2008 Express - Free Download
  3. Bison <-- Download (ensure m4.exe is also included, which it should be)

Optional (but most likely you’ll want):

  1. Perl <-- For Test Suite/Scripts. Strawberry Perl is a great option.
  2. Bazaar <-- If want latest source tree

Tip: Install these in locations where spaces are not in the path. Specifically, watch for the Bison/m4 as there is a known bug with regards to that.

..

Now that that’s out of the way, we can begin. You just need to decide if you want to build from source code you download or from the latest development tree.

This will walk through building from the latest development tree (since the downloaded version requires no extra steps – just grab it from any mirror).

Also, this post assumes you can connect to the Launchpad repository via Bazaar and download the source (i.e., you’ll have to create SSH keys to connect to Launchpad – see this write-up for more details. You might also need Pageant too, if you don’t already have it.)

I. Prerequisite Checks:

C:\>cmake --version
cmake version 2.6-patch 4 C:\>bison --version
bison (GNU Bison) 2.4.1 C:\>m4 --version
m4 (GNU M4) 1.4.13 C:\>perl --version
This is perl 5, version 12, subversion 3 C:\>bzr --version
Bazaar (bzr) 2.4.1

..

II. Obtain Source Code (skip this if you download the source directly from a mirror):

  1. Open Pageant -> Add Key -> Select your SSH Key (for Launchpad)
  2. cd C:\
  3. bzr init-repo –trees mysql-5.5
  4. cd mysql-5.5
  5. bzr branch lp:mysql-server/5.5 mysql-5.5

..

III. Build/Compile Source Code:

  1. cd mysql-5.5
  2. cmake . -DBUILD_CONFIG=mysql_release -G “Visual Studio 9 2008″
  3. Copy m4.exe to $basedir/sql <-- this avoids any m4.exe errors (or fix this permanently if this affects you)
  4. Open Solution in VS: File -> Open -> Project/Solution -> C:\mysql-5.5\mysql-5.5\MySQL.sln
  5. Now build in VS: Build -> Build Solution (or F7)
========== Build: 93 succeeded, 0 failed, 5 up-to-date, 10 skipped ==========

There you have it! (Assuming you have “0 failed”, otherwise, you’ve got some debugging to do.)

..

For those interested, I have full outputs, and common errors (with their solutions) from the entire process here:

MySQL 5.5 Windows Build Appendix : Full Outputs and Common Errors from Building MySQL 5.5 on Windows

..

Build Notes (step #2 above):

The -DBUILD_CONFIG=mysql_release flag uses the same build options used for official releases, which are stored in cmake/build_configurations/mysql_release.cmake.

The simplest you could use is: cmake . -G “Visual Studio 9 2008″

Or you could specify a number of options: cmake . -DMYSQL_SERVER_SUFFIX=-chris -DWITHOUT_FEDERATED_STORAGE_ENGINE=1 -DWITHOUT_BLACKHOLE_STORAGE_ENGINE=1 -G “Visual Studio 9 2008″

The -G lets know which compiler will be used. In this case, I’m using VS 2008 Express. If you were using VS 2005, it’d be “Visual Studio 8 2005″, but I’m not sure if VS 2005 will even work.

This command should end with something like “– Build files have been written to: C:/…” or you’ll need to debug.

Lastly, the cmake command creates the MySQL.sln file and all .vcproj files.

..

IV. Kicking the tires …

Creating a “package” in Visual Studio is quite simple:

In the “Solution Explorer” view (far right-hand side of page), right-click on “PACKAGE” -> then “Build”.

If you have problems with this, it can be pieced together easily enough:

  1. Make main dir mysql-5.5.xx
  2. Make subdir bin/ – copy in all .exe files (from client/debug, sql/debug, */debug, etc.)*
  3. Make subdir data/ – copy from sql/data/
  4. Make subdir scripts/ – copy from scripts/ (at least all perl, sql, and sh scripts)
  5. Make subdir share/ – copy from sql/share/
  6. Create my.ini

* Notes re: .exe files: mysqld.exe is located in /sql/debug/ and mysql.exe is located in /client/debug/. The remaining .exe files are located in /client/debug/, /sql/debug/, /extra/debug/, /libmysql/debug/, /mysys/debug/, /scripts/debug/, /storage/myisam/debug/, /storage/heap/debug/, and /tests/debug/.

Now start mysqld:

mysql> select version();
+------------------+
| version() |
+------------------+
| 5.5.21-debug-log |
+------------------+

Of course you should test it a bit more than that, but I’ll leave that to you.
 
 
..

Related Build Links:

  • Building MySQL and MariaDB on Windows using Visual Studio 2012 Express versus Visual Studio 2010 Express:
    http://www.chriscalender.com/?p=1245
  • How to Build MySQL 5.7 on Windows from Source Code:
    http://www.chriscalender.com/?p=1273
  • How to Build MySQL 5.6 on Windows from Source Code:
    http://www.chriscalender.com/?p=1233
  • How to Build MySQL 5.5 on Windows from Source Code:
    http://www.chriscalender.com/?p=689
  • How to Build MariaDB 10.0 on Windows from Source Code:
    http://www.chriscalender.com/?p=1224
  • How to Build MariaDB 5.5 on Windows from Source Code:
    http://www.chriscalender.com/?p=1087
  • Building MariaDB 5.3 on Windows:
    http://www.chriscalender.com/?p=864
  • Building MariaDB 5.1 on Windows:
    http://www.chriscalender.com/?p=736
  • Building MariaDB 5.1 on Windows Revisited:
    http://www.chriscalender.com/?p=1256
  • Troubleshooting Building MariaDB 5.1 on Windows:
    http://www.chriscalender.com/?p=1259
  • MySQL 5.5 Windows Build Appendix : Full Outputs and Common Errors from Building MySQL 5.5 on Windows:
    http://www.chriscalender.com/?p=720
  • Maintaining (and Building) your MySQL Source Tree on Windows:
    http://www.chriscalender.com/?p=759
  • Resolving the bison.exe m4 Invalid argument Error when building MySQL/MariaDB/XtraDB on Windows:
    http://www.chriscalender.com/?p=798
  • Resolving sasl/sasl.h Not Found during CMake when Building MySQL on Windows:
    http://www.chriscalender.com/?p=1302
  • Resolving Missing ‘sys’ Include Files: devpoll.h, epoll.h, event.h, and queue.h during CMake when Building MySQL on Windows:
    http://www.chriscalender.com/?p=1317
  • Building XtraDB on Windows:
    http://www.chriscalender.com/?p=820


    win7+vs2010源码编译mysql

    最近由于在实习,工作重点在于一些数据库的开发,为了更好的理解数据库的实现机制,目前萌生了要研究一下mysql数据库源码的想法。那么好吧,说干就干,首先我们需要实现对源码的编译,这里我们选择win7+VS2010来实现,但是试了很多次都失败了。这是我多次配置环境时遇到的问题,各种博客文章总是不太完全,或者说没有说明一些遇到的问题的解决方案,这可能跟具体的操作系统和环境有关。本文就说说我安装的情况。

    1. 准备工作

    (1)OS:win7 旗舰版 64位 + VS2010 (2013也试过了)

    (2)mysql 源码(windows版):mysql-5.6.19.zip (下来框选择source code)

    (3)perl tool:ActivePerl-5.16.3.1604-MSWin32-x64-298023.msi

    (4)Cmake:cmake-3.0.0-win32-x86 .exe

    (5)Bison:bison-2.4.1-setup.exe

    安装需要注意的几点,一般安装在根目录下,如C:\Cmake C:\GnuWin32 C:\Perl64 ,当然也可以是其他目录,一般路径不要出现中文字符,空格及特殊字(这个貌似很重要)。具体安装见下面博客:Windows+VS2012环境下编译调试MySQL源码

    除了Bison安装需要注意意外,其他几乎都是默认安装,这些细节最好遵守,以免后续出错。Perl, Cmake, Bison安装完事之后,将他们安装目录下的bin所在路径加入环境变量中(windows环境变量添加),如C:\Cmake\bin.好了至此基本ok。保险起见我们需要验证一下安装是否成功:

      

    2. 开始安装

    在任意你喜欢的盘里面创建一个用于安装的目录:如在D盘创建mysql然后将mysql-5.6.19.zip解压到该目录下,然后在cmd中切换到安装目录,此处即为D:\mysql\mysql-5.6.19,记({install}=D:\mysql\mysql-5.6.19),其下包含如下文件目录:

    然后在{install}下执行以下命令:

    >mkdir bld

    >cd bld

    >cmake ..

    这样你可看到类似如下的输出:

    有一些错误,目前也没有解决,但其实这并不影响我们生成VS下MySQL.sln 工程文件。事实上只要看到下面这个就可以了,各种not found也不要紧。如果采用Cmake 图形界面,其实也差不多了。这里不再赘述。

    下一步我们就可以在VS2010中build solution了(对应生成解决方案),但为了尽可能减少警告或错误,我们首先需要对下述文件进行修改:

    修改的方法很简单,就是将这些文件以UTF-8(带BOM头的)格式保存。一般使用Nodepad++工具等。

    最后一步就是找到{install}\mysql-5.6.19\sql\mysqld.cc中的test_lc_time_sz()函数,将其中的DBUG_ASSERT(0)改为DBUG_ASSERT(1)即可。

    至此我们就完成了将源码转换成VS中工程文件的目的。之后我们就可以build solution了。如果没有错误说明就已经没有问题了,一些小的警告可能是因为C++编译器比C编译器严格的缘故。下一步我们开始调试。

    3. 调试

    然后将mysqld工程的Debug的:属性->调试->命令参数,设为--console,如下:


    然后启动实例,

    这样就可以看到下面的命令行界面:

    cmd下进入到目录{install}\client,然后执行如下命令,就可以开始连接到刚刚开启的mysql服务了。这说明mysql服务已经启动,下一步就是启动mysql客服端,这里我是采用命令行的启动方式。


    好了至此,我们基本完成了在win7下实现在vs下编译调试mysql数据库的目的,下面就可以开始研究源码了。

    4 .新增问题

    (1)vs2010:

    1
    2
    LINK : fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏 [F:\mysql\bld\CMakeFiles\CMakeTmp\cmTryCompileExec2556624813.vcxproj]
    解决办法:这是由于.NET中的cvtres.exe 与 VS2010中的有冲突,删掉VS2010中的cvtres.exe就可以了(目录F:\Install\VS2010\VC\bin),注意install是你安装VS2010的目录。

    为了更好地为后来者指明方向,也为了今后便于自己查询,故做了这个简单的指南。也希望按照这篇文档安装的朋友遇到任何问题可以一起探讨,然后不断完善该文档,以便后来者能够因此而受用,同时营造一个负责人写稿的氛围。

    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(108,5): error MSB3073: 命令“setlocal
    4>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(108,5): error MSB3073: cd D:\mysql-5.6.19\sql
    4>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(108,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd
    4>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(108,5): error MSB3073: D:
    4>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(108,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd
    4>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(108,5): error MSB3073: D:\mysql-5.6.19\client\Debug\echo.exe x64 && cscript //nologo D:/mysql-5.6.19/win/create_def_file.js x64 D:\mysql-5.6.19\sql\Debug\sql.lib D:\mysql-5.6.19\mysys\Debug\mysys.lib D:\mysql-5.6.19\mysys_ssl\Debug\mysys_ssl.lib D:\mysql-5.6.19\dbug\Debug\dbug.lib D:\mysql-5.6.19\strings\Debug\strings.lib > mysqld.def
    4>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(108,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd
    4>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(108,5): error MSB3073: :cmEnd
    4>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(108,5): error MSB3073: endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
    4>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(108,5): error MSB3073: :cmErrorLevel
    4>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(108,5): error MSB3073: exit /b %1
    4>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(108,5): error MSB3073: :cmDone
    4>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(108,5): error MSB3073: if %errorlevel% neq 0 goto :VCEnd
    4>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(108,5): error MSB3073: :VCEnd”已退出,代码为 1。
    _______________________________________________

    问题找到了,发现输出日志里有一行 “输入错误: 没有文件扩展“.js”的脚本引擎。” 
    按照网上的方法:系统安装Dreamwear、UltraEdit、EditPlus后修改了.js文件的默认打开方式。当想直接执行js脚本时就会出现此错误。

    http://blog.csdn.net/clever101/article/details/8757740

    解决办法如下:

    打开注册表编辑器,定位"HKEY_CLASSES_ROOT" > ".js" 这一项,双击默认值将数值数据改为"JSFile"即可,具体如下图:

    后来分析这个主要是由于改变了JScript文件的默认打开方式(不再是由Windows Script Host打开)。

    来源: http://bbs.csdn.net/topics/390817362

How to Build MySQL from Source Code on Windows & compile MySQL on win7+vs2010的更多相关文章

  1. How to build the Robotics Library from source code on Windows

    The Robotics Library is an open source C++ library for robot kinematics, motion planning and control ...

  2. how to build jdk 9 source code

    http://hg.openjdk.java.net/build-infra/jdk9/raw-file/tip/README-builds.html#vs2013 http://royvanrijn ...

  3. How to build windows azure PowerShell Source Code

    Download any version source code of Windows Azure Powershell from https://github.com/Azure/azure-sdk ...

  4. How to compile and install Snort from source code on Ubuntu

    http://www.tuicool.com/articles/v6j2Ab Snort is by far the most popular open-source network intrusio ...

  5. windows下mysql和linux下mysql主从配置

    1. linux下mysql安装版本5.6   windows下mysql版本5.7  不要问我为什么版本不一致  就是想这么搞 2. linux为主服务器   windows为从服务器 3.找到li ...

  6. 退役笔记一#MySQL = lambda sql : sql + &#39; Source Code 4 Explain Plan &#39;

    Mysql 查询运行过程 大致分为4个阶段吧: 语法分析(sql_parse.cc<词法分析, 语法分析, 语义检查 >) >>sql_resolver.cc # JOIN.p ...

  7. Visual Studio 2012,创建工程Build Driver,基于纯Source Code.

    拿到一堆纯代码,怎么去Create Project,设置Include路径,lib路径,要不要Pre-compile技术,配置Project之间的依赖关系. SourcesConverter  Bas ...

  8. MySQL在linux上(cmake)的source code安装方法

    1.安装前准备: 1)必备的包和工具  gcc/g++ :MySQL 5.6开始,需要使用g++进行编译.  cmake  :MySQL 5.5开始,使用cmake进行工程管理,cmake需要2.8以 ...

  9. mysql-5.6.34 Installation from Source code

    Took me a while to suffer from the first successful souce code installation of mysql-5.6.34. Just pu ...

随机推荐

  1. HTML中title前面小图标和网站收藏现实的图标

    网站上的logo实际上是一个“favicon.ico”图片.实现步骤:第一步:制作favicon.ico,大小为16*16毫米:第二步:将“favicon.ico”放到项目的根路径下. 第三步:在所有 ...

  2. C#集合之队列

    队列是其元素按照先进先出(FIFO)的方式来处理的集合. 队列使用System.Collections.Generic名称空间中的泛型类Queue<T>实现.在内部,Queue<T& ...

  3. C#串口通讯中常用的16进制的字节转换

    1.对于通讯协议的十六进制数值进行简单转换 //二进制转十进制Console.WriteLine("二进制 111101 的十进制表示: "+Convert.ToInt32(&qu ...

  4. Django跨域解决方法

    from django.utils.deprecation import MiddlewareMixin class Mymiddle(MiddlewareMixin): def process_re ...

  5. MongoDB数据库初探 --- 认识与安装 && Mongoose安装

    注意: monogdb数据在使用之后必须及时 mongodb.close()否则后台崩溃. 第一部分: MySQL数据库是关系型数据库,但是使用node开发时多用MongoDB数据库,两者各有优势,所 ...

  6. 解决chrome浏览器对于自动填充的input表单添加的默认的淡黄色背景问题 && 一般的浏览器input和button的高度不一致问题

    解决chrome浏览器对于自动填充的input表单添加的默认的淡黄色背景问题 如果我们把一个表单设置位 autofocus ,这时这个表单在获取焦点后就会产生淡黄色的背景,我们就是使用!importa ...

  7. JavaSE_XMind总结

    1 JDBC知识点总结

  8. php的stristr()函数,查找字符

    1.用法,要传2个参数 stristr(string,search):查找并返还匹配后,剩下的部分字符串 查找过程不区分大小写,要区分大小写用 strstr(string,search)少一个字母i ...

  9. haproxy 503 service unavailable no server is avaible to handle this request

    原因: haproxy 对server检测时是对默认页面进行检测,如果没有默认错误,则直接报503错误,不会转发到相应的server上去. 解决方法: 添加 option httpchk 检测页面位置 ...

  10. git submodule的使用

    1.在项目中使用Submodule 为当前工程添加submodule,命令如下:git submodule add 仓库地址 路径仓库地址:是指子模块仓库地址URL.路径:指将子模块放置在当前工程下的 ...