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. WeakHashMap源码分析

    WeakHashMap是一种弱引用map,内部的key会存储为弱引用, 当jvm gc的时候,如果这些key没有强引用存在的话,会被gc回收掉, 下一次当我们操作map的时候会把对应的Entry整个删 ...

  2. StringBuffer类和String类的区别

    StringBuffer是使用缓冲区的,本身也是操作字符串的,但与String类不同,String类的内容一旦声明后是不可改变的,改变的只是其内存的指向,而StringBuffer类的对象内容是可以改 ...

  3. [BZOJ 4857][Jsoi2016]反质数序列

    传送门 $ \color{green} {solution : } $ 因为 $ 1 $ 的个数我们最多只能选一个,所以剩下的数如果组成素数那么只有一奇一偶,显然是个二分图模型 #include &l ...

  4. 6. Javscript学习笔记——BOM

    6. BOM 6.1 widow对象 全局作用域: window是浏览器的一个实例 window对象同时扮演着ECMAScript中的Global对象的角色,因此所有在全局作用域中声明的变量.函数都会 ...

  5. BZOJ - 3295 三维偏序 空间转换

    题意:动态逆序对,共m次删除操作,求每次操作前的逆序对个数 删除操作转换为添加操作,首先对时间a进行简单排序 然后用cdq分治处理b维,树状数组处理c维 此时需要求的是对于某有序组\((a,b,c)\ ...

  6. FreeRTOS-03中断测试

    根据正点原子FreeRTOS视频整理 单片机:STM32F207VC FreeRTOS源码版本:v10.0.1 portDISABLE_INTERRUPTS(); /*关中断*/portENABLE_ ...

  7. Excel2007使用SQL语句

    Excel2007使用SQL语句 假如金三导出表格如下:[入库查询dddd.xls] 第1步 第2步 第3步 找到[入库查询dddd.xls] 比如 SELECT 纳税人名称, sum(实缴金额) F ...

  8. java 实现一套流程管理、流转的思路(伪工作流)

    在做某个管理项目时,被要求实现一套流程管理,比如请假的申请审批流程等,在参考了很多资料,并和同事讨论后,得到了一个自主实现的流程管理. 以下提供我的设计思路,知道了思路,实现起来就简单很多了. 首先我 ...

  9. JPA为字段设置默认值

    http://blog.csdn.net/u011983531/article/details/51286839 在使用JPA时,如果需要为属性设置默认值,很自然的,你可能会想到用下面的方式. @Co ...

  10. Java入门系列-21-多线程

    什么是线程 在操作系统中,一个应用程序的执行实例就是进程,进程有独立的内存空间和系统资源,在任务管理器中可以看到进程. 线程是CPU调度和分派的基本单位,也是进程中执行运算的最小单位,可完成一个独立的 ...