Windows+VS2012环境下编译调试MySQL源码(四)



工程和解决方案生成完毕,现在我们可以在VS2012中打开编译了,双击C:\MySQLSC\bld\MySQL.sln以打开解决方案。




工程好多啊,共128个项目。


解决方案中的默认启动项目是【ALL_Build】,不要修改它。



开始编译之前,我们先做一些准备工作,可以有效地减少编译过程中一些不必要的警告和错误。


用文本编辑程序,如【EditPlus】或【Notepad++】等(注意不要用Word等字处理软件)打开如下文件,另存为Unicode编码:



=============================

重要:

需要修改编码的文件列表

C:\MySQLSC\strings\ctype-czech.c

C:\MySQLSC\strings\ctype-latin1.c

C:\MySQLSC\strings\decimal.c

C:\MySQLSC\mysys\thr_mutex.c

c:\mysqlsc\storage\innobase\include\ut0mem.h

C:\MySQLSC\sql\sql_locale.cc



需要修改编码的文件列表

=============================

注意,有些文件直接用EditPlus打开有问题的时候,可以先以[UTF-8]编码打开,之后再存为[Unicode]编码。




举例如下:










上面列表中的文件都作类似处理。


OK,我们现在选择【Debug】【x64】,按【F7】开始编译。




编译的过程会有些长,耐心等待吧。


编译整体是顺利的,只有一个地方(编译initial_database项目时)出现了错误,错误信息如下:


==================================================

125>------ 已启动生成: 项目: initial_database, 配置: Debug x64 ------
121>     正在创建库 C:/MySQLSC/bld/plugin/semisync/Debug/semisync_slave.lib 和对象 C:/MySQLSC/bld/plugin/semisync/Debug/semisync_slave.exp
125>  Building Custom Rule C:/MySQLSC/sql/CMakeLists.txt
125>  CMake does not need to re-run because C:\MySQLSC\bld\sql\CMakeFiles\generate.stamp is up-to-date.
125>  Generating initdb.dep
120>     正在创建库 C:/MySQLSC/bld/plugin/semisync/Debug/semisync_master.lib 和对象 C:/MySQLSC/bld/plugin/semisync/Debug/semisync_master.exp
121>  semisync_slave.vcxproj -> C:\MySQLSC\bld\plugin\semisync\Debug\semisync_slave.dll
120>  semisync_master.vcxproj -> C:\MySQLSC\bld\plugin\semisync\Debug\semisync_master.dll
124>     正在创建库 C:/MySQLSC/bld/plugin/password_validation/Debug/validate_password.lib 和对象 C:/MySQLSC/bld/plugin/password_validation/Debug/validate_password.exp
124>  validate_password.vcxproj -> C:\MySQLSC\bld\plugin\password_validation\Debug\validate_password.dll
125>  Executing C:/MySQLSC/bld/sql/Debug/mysqld.exe --no-defaults --console --bootstrap --lc-messages-dir=C:/MySQLSC/bld/sql/share --basedir=. --datadir=. --default-storage-engine=MyISAM --default-tmp-storage-engine=MyISAM --loose-skip-ndbcluster --max_allowed_packet=8M --net_buffer_length=16K
125>  
125>  input file bootstrap.sql, current directory C:/MySQLSC/bld/sql/data
125>  
125>  CMake Error at C:/MySQLSC/bld/sql/create_initial_db.cmake:103 (MESSAGE):
125>    Could not create initial database
125>  
125>      
125>     Assertion failed: 0, file ..\..\sql\mysqld.cc, line 4191
125>  
125>    R6010
125>  
125>    - abort() has been called
125>  
125>    14:37:36 UTC - mysqld got exception 0x80000003 ;
125>  
125>    This could be because you hit a bug.  It is also possible that this binary
125>  
125>    or one of the libraries it was linked against is corrupt, improperly built,
125>  
125>    or misconfigured.  This error can also be caused by malfunctioning
125>    hardware.
125>  
125>    We will try our best to scrape up some info that will hopefully help
125>  
125>    diagnose the problem, but since we have already crashed,
125>  
125>    something is definitely wrong and this may fail.
125>  
125>    
125>  
125>    key_buffer_size=0
125>  
125>    read_buffer_size=131072
125>  
125>    max_used_connections=0
125>  
125>    max_threads=151
125>  
125>    thread_count=0
125>  
125>    connection_count=0
125>  
125>    It is possible that mysqld could use up to
125>  
125>    key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 59679
125>    K bytes of memory
125>  
125>    Hope that's ok; if not, decrease some variables in the equation.
125>  
125>    
125>  
125>    Thread pointer: 0x0
125>  
125>    Attempting backtrace.  You can use the following information to find out
125>  
125>    where mysqld died.  If you see no messages after this, something went
125>  
125>    terribly wrong...
125>  
125>    7ff7447ecfd5 mysqld.exe!my_sigabrt_handler()[my_thr_init.c:448]
125>  
125>    7ff744dc94fc mysqld.exe!raise()[winsig.c:593]
125>  
125>    7ff744dd5140 mysqld.exe!abort()[abort.c:82]
125>  
125>    7ff744dc6a9b mysqld.exe!_wassert()[assert.c:355]
125>  
125>    7ff74429cdf3 mysqld.exe!test_lc_time_sz()[mysqld.cc:4191]
125>  
125>    7ff74429d19e mysqld.exe!win_main()[mysqld.cc:4399]
125>  
125>    7ff74429da92 mysqld.exe!mysql_service()[mysqld.cc:4752]
125>  
125>    7ff74429e36f mysqld.exe!mysqld_main()[mysqld.cc:4949]
125>  
125>    7ff74429102f mysqld.exe!main()[main.cc:26]
125>  
125>    7ff744dc111c mysqld.exe!__tmainCRTStartup()[crt0.c:241]
125>  
125>    7ff744dc125e mysqld.exe!mainCRTStartup()[crt0.c:164]
125>  
125>    7ff8310f15cd KERNEL32.DLL!BaseThreadInitThunk()
125>  
125>    7ff831cb43d1 ntdll.dll!RtlUserThreadStart()
125>  
125>    The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
125>  
125>    information that should help you find out what is causing the crash.
125>  
125>  
125>  
125>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets(172,5): error MSB6006: “cmd.exe”已退出,代码为 1。

=============================================================


这个编译错误的原因非常简单,是由于代码中的一个DEBUG断言引致的(我在上面已经高亮标识出来了),修改也非常简单,在VS2012中定位到sql工程下mysqld.cc文件的4191行


DBUG_ASSERT(0);

改为

DBUG_ASSERT(1);

即可。




再次编译,这回非常OK,没有错误信息了。




下一回,我们就可以运行我们编译出来的MySQL,并试着调试它了。


(待续。。。)



  • 4
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值