MySQL交叉编译

来源:互联网 发布:联通合约机 知乎 编辑:程序博客网 时间:2024/04/30 15:03

1. MySQL需要ncurses库的支持,首先下载ncurses-5.7库并进行交叉编译

    CFLAGS="-O3" CC=/opt/arm-v4t-linux-gnueabi/gcc-4.1.2-glibc-2.5-kernel-2.6.18/bin/arm-v4t-linux-gnueabi-gcc CXX=/opt/arm-v4t-linux-gnueabi/gcc-4.1.2-glibc-2.5-kernel-2.6.18/bin/arm-v4t-linux-gnueabi-g++ ./configure --host=arm-v4t-linux-gnueabi --prefix=/home/ncurses-5.7/


2. 下载MySQL-5.1.70

3. 解压

4. 配置

CFLAGS="-O3" CC=/opt/arm-v4t-linux-gnueabi/gcc-4.1.2-glibc-2.5-kernel-2.6.18/bin/arm-v4t-linux-gnueabi-gcc CXX=/opt/arm-v4t-linux-gnueabi/gcc-4.1.2-glibc-2.5-kernel-2.6.18/bin/arm-v4t-linux-gnueabi-g++ CXXFLAGS="-O3 -felide-constructors -fno-exceptions -fno-rtti" ./configure --host=arm-v4t-linux-gnueabi --prefix=/home/mysql-5.1.17 --with-mysqld-ldflags=-all-static --with-client-ldflags="-all-static" ac_cv_sys_restartable_syscalls='no' --with-named-curses-libs=/home/ncurse/lib/libncurses.a
make
make install


5. 编译过程

   出错:
checking for restartable system calls... configure: error: in `/opt/crosslib/mysql-5.1.34':
configure: error: cannot run test program while cross compiling
See `config.log' for more details.
###增加一句ac_cv_sys_restartable_syscalls='no'
CC=powerpc-linux-gcc ./configure --prefix=/opt/crosslib/mysql --host=powerpc-linux ac_cv_sys_restartable_syscalls='no'
配置成功

make
出错:
powerpc-linux-g++ -O3 -fno-implicit-templates -fno-exceptions -fno-rtti -rdynamic -o gen_lex_hash gen_lex_hash.o  ../vio/libvio.a ../mysys/libmysys.a ../dbug/libdbug.a ../regex/libregex.a ../strings/libmystrings.a -lz -lpthread -lcrypt -lnsl -lm -lpthread  
make[2]: Leaving directory `/opt/crosslib/mysql-5.1.34/sql'
./gen_lex_hash > lex_hash.h-t
/bin/sh: ./gen_lex_hash: cannot execute binary file
make[1]: *** [lex_hash.h] Error 126
make[1]: Leaving directory `/opt/crosslib/mysql-5.1.34/sql'
make: *** [all-recursive] Error 1
这时前面的 准备就有用了
cp ../mysql-pc/sql/gen_lex_hash sql/
然后再次make
又出错:
sql_parse.cc:5504:21: error: operator '<' has no left operand
make[3]: *** [sql_parse.o] Error 1
make[3]: Leaving directory `/opt/crosslib/mysql-5.1.34/sql'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/opt/crosslib/mysql-5.1.34/sql'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/opt/crosslib/mysql-5.1.34/sql'
make: *** [all-recursive] Error 1
我查了以下,但是没有查到powerpc 中STACK_DIRECTION的值是多少,
于是,先不管了,在sql_parse.cc文件的前面添加一行:
# define STACK_DIRECTION 1
再次make
再出错:
In file included from ../include/my_global.h:80,
                 from mysql_priv.h:31,
                 from sql_parse.cc:17:
../include/my_config.h:1133:1: warning: "STACK_DIRECTION" redefined
sql_parse.cc:15:1: warning: this is the location of the previous definition
sql_parse.cc:5504:21: error: operator '<' has no left operand
make[3]: *** [sql_parse.o] Error 1
于是用命令
find . -name my_config.h
gedit ./include/my_config.h
从网上看到这么一段
要学习溢出技术就必须了解堆栈结构,PowerPC的堆栈结构和ia32有很大不同,PowerPC没有类似ia32里ebp这个指针,它只使用r1寄存器把整个堆栈构成一个单向链表,其增长方向是从高地址到低地址,而本地变量的增长方向也是从低地址到高地址的
于是
把my_config.h中的# define STACK_DIRECTION 后面增加 -1
再次make
最后显示:
make[2]: Leaving directory `/opt/crosslib/mysql-5.1.34/server-tools/instance-manager'
make[1]: Leaving directory `/opt/crosslib/mysql-5.1.34/server-tools'
Making all in win
make[1]: Entering directory `/opt/crosslib/mysql-5.1.34/win'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/opt/crosslib/mysql-5.1.34/win'
应该就是make成功了

使用:

./mysql_install_db --user=root --force

./mysqld_safe --socket=/tmp/mysql.sock &

./mysql

就可以成功了

原创粉丝点击