一直想着要了解一下mysql数据库,现在编译器的研究终于告一段落,正式动手搞起来。
今天就从源码的下载,安装开始,个人使用的Ubuntu14.04。
1,首先,下载最新的源码: wget http://mysql.mirror.kangaroot.net/Downloads/MySQL-6.0/mysql-6.0.11-alpha-linux-x86_64-glibc23.tar.gz。
太慢了,换个源,换成sohu:http://mirrors.sohu.com/mysql/MySQL-6.0/myqsl-6.0.11-alpha-linux-x86_64-glibc23.tar.gz,这个比较快。
解压,并没有发现源代码,原来这是个编译过后的包,无法用于做代码分析。
接着找,实际上6.0.11版本的源代码应该是这个:http://mirrors.sohu.com/mysql/MySQL-6.0/mysql-6.0.11-alpha.tar.gz。
down下来,解压,终于找到configure和automake等工具,这个应该就是源代码无疑了,
2,接下来就是编译安装了
解压之后可以看一个BUILD文件夹,里面都是一些shell脚本。
因为是出于源码研究的目的,所以选择装一个debug版本,选择使用compile-pentium-debug
我们现在来看一下,这个shell里面都有些什么
#! bin/sh
path = 'dirname $0'
set -- "$@" --with-debug=full
. "$path/SETUP.sh"
extra_flags="$pentium_cflags $debug_cflags"
extra_configs="$pentium_configs $debug_configs"
. "$path/FINISH.sh"
可以看到实际上就是执行了两个shell,配置了两个变量,即平台相关的参数和debug配置。
在工程根目录下执行BUILD/compile-pentium-debug --prefix=$HOME/mysql-elf,发现执行出错,缺少aclocal,
新装的虚拟机缺少automake工具链,于是sudo apt-get install autoconf
缺少libtoolize,继续完善环境:sudo apt-get install libtool
提示No curses/termcap library found,缺少ncurses,继续完善:sudo apt-get install libncurses5-dev
提示:Falcon must be compiled with support for C++ exceptions enabled.
Please adjust your compiler flags or disable support for Falcon (--without-plugin-falcon).
网上查了下:Falcon是mysql提供的一种新的存储引擎,需要c++提供支持,具体请看这里
终于,configure完成,可以执行编译了
但是编译继续出错,出错信息:***[do_dbi_check] error.
网上查了下:貌似是因为mysql高版本跟gcc 4.5之间有不兼容,不过这里提供了解决办法:把do_abi_check的执行语句删掉即可,本人未深究原因。
继续make&&make install即可完成安装