[转帖]交叉编译mysql的全过程_MySQL, Oracle及数据库讨论区_Weblogic技术|Tuxedo技术|中间件技术|Oracle论坛|JAVA论坛|Linux/Unix技术|hadoop论坛_联动北方技术论坛  
网站首页 | 关于我们 | 服务中心 | 经验交流 | 公司荣誉 | 成功案例 | 合作伙伴 | 联系我们 |
联动北方-国内领先的云技术服务提供商
»  游客             当前位置:  论坛首页 »  自由讨论区 »  MySQL, Oracle及数据库讨论区 »
总帖数
2
每页帖数
101/1页1
返回列表
0
发起投票  发起投票 发新帖子
查看: 2430 | 回复: 1   主题: [转帖]交叉编译mysql的全过程        下一篇 
jinquan
注册用户
等级:少尉
经验:390
发帖:89
精华:0
注册:2012-3-1
状态:离线
发送短消息息给jinquan 加好友    发送短消息息给jinquan 发消息
发表于: IP:您无权察看 2014-11-19 10:25:41 | [全部帖] [楼主帖] 楼主

交叉编译mysql

1,下载http://dev.mysql.com/downloads/mysql/5.1.html,注意:是下载最下面的源码包

2,解压

3,配置

CC=powerpc-linux-gcc ./configure --prefix=/opt/crosslib/mysql --host=powerpc-linux


出错:

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'


配置成功

4,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
#####参考了网易博客的方法(他说那是由于编译的arm类型的程序不能在PC上运行造成的),
make clean
./configure --prefix=/opt/crosslib/mysql ; 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'


不管它

cd ..
mv mysql-5.1.34 mysql-pc


重新解压tar -xvf mysql-5.1.34.tar.gz

重新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成功了

5,make install
6,make clean
####参考网易那个设置一下


把拷贝到

启动板子

运行

# mysql_install_db --user=root
WARNING: The host '(none)' could not be looked up with resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !
Installing MySQL system tables...
/opt/crosslib/mysql/libexec/mysqld: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
Installation of system tables failed!  Examine the logs in
/opt/crosslib/mysql/var for more information.
You can try to start the mysqld daemon with:
shell> /opt/crosslib/mysql/libexec/mysqld --skip-grant &
and use the command line tool /opt/crosslib/mysql/bin/mysql
to connect to the mysql database and look at the grant tables:
shell> /opt/crosslib/mysql/bin/mysql -u root mysql
mysql> show tables
Try 'mysqld --help' if you have problems with paths.  Using --log
gives you a log in /opt/crosslib/mysql/var that may be helpful.
The latest information about MySQL is available on the web at
http://www.mysql.com/.  Please consult the MySQL manual section
'Problems running mysql_install_db', and the manual section that
describes problems on your OS.  Another information source are the
MySQL email archives available at http://lists.mysql.com/.
Please check all of the above before mailing us!  And remember, if
you do mail us, you MUST use the /opt/crosslib/mysql/bin/mysqlbug script!
##于是在/etc/hosts下添加一行
(none)          localhost.localdomain   localhost


并且拷贝.so

cp /opt/eldk/ppc_4xxFP/lib/libstdc++.so.6.0.9 /media/disk/lib/
###再次启动运行
# mysql_install_db --user=root
WARNING: The host '(none)' could not be looked up with resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !
Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/opt/crosslib/mysql/bin/mysqladmin -u root password 'new-password'
/opt/crosslib/mysql/bin/mysqladmin -u root -h (none) password 'new-password'
Alternatively you can run:
/opt/crosslib/mysql/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /opt/crosslib/mysql ; /opt/crosslib/mysql/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /opt/crosslib/mysql/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /opt/crosslib/mysql/bin/mysqlbug script!
The latest information about MySQL is available at http://www.mysql.com/
Support MySQL by buying support/licenses from http://shop.mysql.com/
# mysqld_safe --socket=/tmp/mysql.sock &
# 700101 00:04:22 mysqld_safe Logging to '/var/log/mysqld.log'.
700101 00:04:22 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
#mysql


出错:

mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory


又缺库

#######

拷贝好库之后,终于成功了!!!

#mysql
Welcome to the MySQL monitor.  Commands end with ; or "g.
Your MySQL connection id is 1
Server version: 5.1.34 Source distribution
No entry for terminal type "vt102";
using dumb terminal settings.
Type 'help;' or '"h' for help. Type '"c' to clear the current input statement.
mysql>


昨天还找了一个程序试了一下,输出没有问题。

--转自 北京联动北方科技有限公司




赞(0)    操作        顶端 
hui.chen
注册用户
等级:大校
经验:6070
发帖:48
精华:4
注册:2014-2-7
状态:离线
发送短消息息给hui.chen 加好友    发送短消息息给hui.chen 发消息
发表于: IP:您无权察看 2014-11-19 10:41:32 | [全部帖] [楼主帖] 2  楼

本论坛也有mysql的安装包,http://bbs.landingbj.com/f-0-RJXZ-1-0.html  数据库文件夹下面


u=2871144702,1362725177&fm=21&gp=0.jpg.gif


赞(0)    操作        顶端 
总帖数
2
每页帖数
101/1页1
返回列表
发新帖子
请输入验证码: 点击刷新验证码
您需要登录后才可以回帖 登录 | 注册
技术讨论