ARM技术论坛
直播中

辉绿荫跑道

4年用户 4经验值
擅长:嵌入式技术
私信 关注

移植Mysql到ARM平台

本帖最后由 辉绿荫跑道 于 2020-10-20 17:03 编辑

目前我使用的Mysql的版本为mysql-5.1.72.tar.gz,可在网上下载对应版本的mysql的压缩包。由于移植mysql库需要用到libncurses.a静态库,所以在移植mysql之前,我们需要先移植ncurses,目前我使用的ncurses库版本为ncurses-5.9.tar.gz,以下是移植ncusrse库的步骤:
(1)解压库文件:
tar zxvf ncurses-5.9.tar.gz  -C  /opt/mysql/ncurses(2)进入库文件路径,配置环境变量:
CC=arm-linux-gnueabihf-gcc ./configure –host=arm-linux-gnueabihf -prefix=/opt/mysql/ncurse –enable-static
(3)编译、安装:
make
make install
安装ncurses库时出现问题:arm-linux-ranlib command not found
解决办法:  先用下sudo -i命令取得root权限。然后再执行make install。
由于移植mysql需要用到一个本地编译的文件gen_lex_hash,所以需要先本地编译mysql,操作如下:
在./configure前需要屏蔽部分代码,否则配置环境变量会出错,无法配置,
vi ./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 …..!”
        #{ { $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

这样的代码总共有四处,都要屏蔽掉,分别在26302,48120,48226,48439行。

CC=gcc ./configure --prefix=/opt/mysql/mysql
make
不需要make install
本地编译此版本的mysql没有出错,然后交叉编译,操作如下:
(1)./configure --prefix=/opt/mysql/mysql --host=arm-linux-gnueabihf CC=arm-linux-gnueabihf-gcc --enable-static --enable-shared
安装mysql时出现:configure: error: No curses/termcap library found
若是安装以下后仍然 .configure 后出现上面问题:
sudo apt-cache search ncurses
sudo apt-get install libncurses5-dev
采用如下配置,重新.configure,即可通过:
./configure --host=arm-linux-gnueabihf --enable-static --with-named-curses-libs=/opt/mysql/ncurses/lib/libncurses.a --prefix=/opt/mysql/mysql --without-debug --without-docs --without-man --without-bench --with-charset=gb2312 --with-extra-charsets=ascii,latin1,utf8


(2)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
解决办法:
需要将刚才我们编译好的本地版本的sql目录下面的gen_lex_hash,拷贝到现在交叉编译时对应的sql目录覆盖即可;
覆盖完成后输入如下命令:
root@ubuntu:/opt/lib/mysql-5.1.51# touch –m sql/gen_lex_hash
再次make应该又会出现新的问题:
make 出现问题:
sql_parse.cc:5432:21: operator '<' has no left operand
解决办法:
由于宏变量STACK_DIRECTION没有定义初值,所以找到sql_parse.cc文件,将第5444行的前面一行加入#define STACK_DIRECTION 1
之后再次make即可编译通过;
(3)make install
搭建环境,本文档只提供mysql安全模式下操作登陆操作mysql。
安装完成后,将安装后的文件打包拷贝到arm板上对应的目录下进行解压;
进入解压的目录的bin文件下
cd /opt/mysql/mysql/bin
mysqld_safe --skip-grant-tables &      
现在应该可以登陆mysql,
mysql -u root -p123456
具体登陆操作mysql,可网上搜索,移植mysql完成。









更多回帖

发帖
×
20
完善资料,
赚取积分