织梦CMS - 轻松建站从此开始!

罗索

交叉编译mysql的全过程

落鹤生 发布于 2012-09-04 17:26 点击:次 
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 `/o
TAG:

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

#####参考了博客(http://www.rosoo.net/a/201209/16250.html)的方法(他说那是由于编译的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>

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

(yoleung)
本站文章除注明转载外,均为本站原创或编译欢迎任何形式的转载,但请务必注明出处,尊重他人劳动,同学习共成长。转载请注明:文章转载自:罗索实验室 [http://www.rosoo.net/a/201209/16252.html]
本文出处:博客园 作者:yoleung 原文
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片
栏目列表
将本文分享到微信
织梦二维码生成器
推荐内容