资源描述
MySQL5.1.66移植到ARM
郭强
一、 MySQL5.1.66的ARM移植
1. 下载MySQL5.1.66,ncurses-5.6,termcap-1.3.1的源码包,解压在宿主机上,并制作两个解压包副本
安装termcap-1.3.1库
依次输入以下命令
tar xvzf termcap-1.3.1.tar.gz (回车)
cd termcap-1.3.1 (回车)
./configure --prefix=/usr (回车)
make (回车)
make install (回车)
2. 编译Mysql PC版本
下载压缩包到本地,并解压mysql-5.1.66.tar.gz到/home
tar zxvf mysql-5.1.66.tar.gz –C ./
进入解压得到的源码目录中:
cd mysql-5.1.66
运行configure,生成makefile:
./configure --prefix=/usr/local/mysql
如果出现以下提示信息(没有出错就不用管):
checking for termcap functions library… configure: error: No curses/ termcap library found
那么就安装termcap库进行解决
安装完成之后,再次运行
./configure --prefix=/usr/local/mysql
一切正常,直接开始运行make编译源代码:
make
Make完成后,将这个文件夹改名为mysql-5.1.66-pc留作备用。
3. 交叉编译MySQL –ARM版本
根据最前面提到的问题,要交叉编译MySQL -ARM版本,首先我们得先得到一个交叉编译过的libncurses.a的库,所以为了方便,我们先做这一步。
交叉编译ncurses-5.6.tar.gz
先下载压缩包到本地,并解压ncurses-5.6.tar.gz到/home/ncurses-5.6:
tar zxvf ncurses-5.6.tar.gz -C ./
进入解压得到的源码目录中:cd ncurses-5.6
运行configure,生成makefile:(我这里将ncurses安装到了/usr/local/ncurses)
CC=arm-linux-gcc
LD=arm-linux-ld
RANLIB=arm-linux-ranlib
./configure --host=arm-linux --prefix=/usr/local/ncurse --enable-static
直接开始运行make编译源代码:make
直接开始安装:make install
安装完成就可以拿来备用了。
重新解压mysql-5.1.66.tar.gz到/home/mysql-5.1.66:
tar zxvf mysql-5.1.66.tar.gz -C ./
进入解压得到的源码目录中:
cd mysql-5.1.66
修改configure,注释掉不支持交叉编译的部分
gedit configure
找到所有如下语句:
if test "$cross_compiling" = yes; then
{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling See \`config.log' for more details." >&5
$as_echo "$as_me: error: cannot run test program while cross compiling See \`config.log' for more details." >&2;}
{ (exit 1); exit 1; }; }; }
else
修改成
if test "$cross_compiling" = yes; then
echo “skip corss_compiling test”;
#{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
# $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
#{ { $as_echo "$as_me:$LINENO: error: cannot run test program while
# cross compiling See \`config.log' for more details." >&5
#$as_echo "$as_me: error: cannot run test program while cross compiling #See \`config.log' for more details." >&2;}
#{ (exit 1); exit 1; }; }; }
Else
保存推出原文那种注释方法,还需要找到离这段代码段比较远的一处#fi,这个本来就容易出问题,而且应该有将近4段类似代码,
4. 交叉编译MySQL
有了这些准备工作,这个时候就可以交叉编译MySQL了。
配置configure
CC=arm-linux-gcc
LD=arm-linux-ld
RANLIB=arm-linux-ranlib
./configure --host=arm-linux --enable-static --with-named-curses-libs=/usr/local/ncurses/lib/libncurses.a --prefix=/usr/local/mysql --without-debug --without-docs --without-man --without-bench --with-charset=gb2312 --with-extra-charsets=ascii,latin1,utf8 --localstatedir=/usr/local/mysql/data/ --with-low-memory(未测试)
首先是使用libncurses.a库,在交叉编译MySQL-ARM版本的第一步,交叉编译ncurses-5.6时,我的ncurse安装目录就是/usr/local/ncurses/, 第二就是我将交叉编译的MySQL也安装到了/usr/local/mysql,这个是因为我在编译PC版本的MySQL时只是使用了make,并没有make install。如果你也需要使用PC上的MySQL,并且当时使用了make install,这里就需要注意目录问题。
直接开始运行make编译源代码:
make 出现错误:
make[2]: Leaving directory `/opt/mysql-5.5.3-m3/sql'./gen_lex_hash > lex_hash.h-t/bin/sh: ./gen_lex_hash: cannot execute binary file
这个时候就需要将刚才我们编译好的PC版本的$MYSQL\sql\目录下面的gen_lex_hash,然后cp到现在交叉编译时对应的$MYSQL\sql\目录覆盖即可。
这时注意:覆盖完成后不要急于make,这时输入如下命令:
touch –m sql/gen_lex_hash
然后再执行make
make
上面的命令是改变gen_lex_hash的最后修改时间,这样做的目的是告诉编译器gen_lex_hash已经是最新的了,不要重新生成它,否则编译器检查gen_lex_hash和它的依赖文件的最后修改时间会发现gen_lex_hash比它的依赖文件更旧,就会重新交叉编译生成它,这样不管我们做几次覆盖的工作错误都还会再现.
出现错误:
sql_parse.cc:5432:21: operator '<' has no left operand
解决办法:
这是由于宏变量STACK_DIRECTION没有定义初值,网上查找资料发现arm中定义STACK_DIRECTION为1,所以找到sql_parse.cc文件,将第5432行的前面一行加入#define STACK_DIRECTION 1
这时就应该能够正常编译,编译结束后就可以执行install
make install
至此,编译arm平台的MySQL基本完成
5. 配置MySQL
修改MySQL的配置文件
cp /my-f /etc/f
vi f
修改相应位置[mysqld]、[mysql client]上的socket
socket = /usr/local/mysql/mysql.sock
修改/mysql文件夹的权限:
chmod -R 755 mysql
展开阅读全文