mysql在mipsel64下的交叉编译并上传到开发板测试

  1. #在官网下载要求5.1.45版本

正在上传…重新上传取消

  1. #交叉编译器

loongson_compiler_20220701.zip放到虚拟机ubuntu18

按文档要求在/opt下解压并配置环境变量。

  1. #mysql编译

#下载5.145版本的mysql

#查看一下configure的编译帮助

root@lsdk:/opt/mysql-5.1.45# ./configure –help

Some influential environment variables:

  CC          C compiler command

  CFLAGS      C compiler flags

  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a

              nonstandard directory <lib dir>

  LIBS        libraries to pass to the linker, e.g. -l<library>

  CPPFLAGS    C/C++/Objective C preprocessor flags, e.g. -I<include dir> if

              you have headers in a nonstandard directory <include dir>

  CPP         C preprocessor

  CXX         C++ compiler command

  CXXFLAGS    C++ compiler flags

  CXXCPP      C++ preprocessor

  CCAS        assembler compiler command (defaults to CC)

  CCASFLAGS   assembler compiler flags (defaults to CFLAGS)

#先用一个配置来测试编译

root@lsdk:/opt/mysql-5.1.45# ./configure --prefix=/usr/local/mysql --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=gbk,gb2312 --host=mips64el-linux CFLAGS=" -std=gnu89"

2021226 mysql5.5,mysql源码安装开始使用cmake了。下面是介绍configure选项如何映射到CMake的等值参数。 1.

提示如下错误

正在上传…重新上传取消

#查百度知可以降级,参考(100条消息) 编译MySQL5.0.15_happytree001的博客-CSDN博客

这里出现了从ulong转换为longlong的情况,导致编译不过
增加选项-std=gun++98使之不使用高版本特性,类似降级使用

$ CXXFLAGS="-std=gnu++98" ./configure --prefix=/usr/local/mysql5.0.15

  • 1

make && sudo make install

MYSQL_PATH=/usr/local/mysql-5.0.16-i686-linux-rhel4

CFLAGS="-O3" CC=gcc4 CXX=gcc4 CXXFLAGS="-O3 -felide-constructors -fno-exceptions -fno-rtti" \
./configure \
--prefix=$MYSQL_PATH --with-libwrap=/usr/lib \
--with-ndbcluster --with-ndb-shm \
--with-ndb-sci \
--enable-assembler --with-mysqld-ldflags=-all-static

make -j $(nproc) && make install

添加更多选项来执行

root@lsdk:/opt/mysql-5.1.45# CXXFLAGS="-std=gnu++98" CPPFLAGS="-std=gnu++98" CFLAGS="-std=gnu++98" ./configure --prefix=/usr/local/mysql --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=gbk,gb2312 --host=mips64el-linux

root@lsdk:/opt/mysql-5.1.45# CXXFLAGS="-std=c++98  -Wno-narrowing " CPPFLAGS="-std=c++98  -Wno-narrowing "  ./configure --prefix=/usr/local/mysql --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=gbk,gb2312 --with-named-curses-libs=/usr/local/ncurses/libncurses.a--host=mips64el-linux

#ok的交叉脚本

root@lsdk:/opt/mysql-5.1.45# CXXFLAGS="-std=c++98  -Wno-narrowing " CPPFLAGS="-std=c++98  -Wno-narrowing "  ./configure --prefix=/usr/local/mysql --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=gbk,gb2312 --with-named-curses-libs=/usr/local/ncurses/libncurses.a --host=mips64el-linux

#在交叉编译环境时需要修改configure脚本。具体如下

3.2 修改configure,共四处

3.2.1

----------------------------------------------------------------------------------------------

26302   if test "$cross_compiling" = yes; then

26303   echo "skip...!"

26304 #  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5

26305 #$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}

26306 #{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling

26307 #See \`config.log' for more details." >&5

26308 #$as_echo "$as_me: error: cannot run test program while cross compiling

26309 #See \`config.log' for more details." >&2;}

26310 #   { (exit 1); exit 1; }; }; }

26311 else

-------------------------------------------------------------------------------------------------

3.2.2

-------------------------------------------------------------------------------------------------

48121   if test "$cross_compiling" = yes; then

48122   echo "skip...!"

48123 #  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5

48124 #$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}

48125 #{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling

48126 #See \`config.log' for more details." >&5

48127 #$as_echo "$as_me: error: cannot run test program while cross compiling

48128 #See \`config.log' for more details." >&2;}

48129 #   { (exit 1); exit 1; }; }; }

48130 else

-------------------------------------------------------------------------------------------------

3.2.3

-------------------------------------------------------------------------------------------------

48228   if test "$cross_compiling" = yes; then

48229   echo "skip...!"

48230 # { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5

48231 #$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}

48232 #{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling

48233 #See \`config.log' for more details." >&5

48234 #$as_echo "$as_me: error: cannot run test program while cross compiling

48235 #See \`config.log' for more details." >&2;}

48236 #   { (exit 1); exit 1; }; }; }

48237 else

-------------------------------------------------------------------------------------------------

3.2.4

-------------------------------------------------------------------------------------------------

48442   if test "$cross_compiling" = yes; then

48443   echo "skip...!"

48444 # { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5

48445 #$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}

48446 #{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling

48447 #See \`config.log' for more details." >&5

48448 #$as_echo "$as_me: error: cannot run test program while cross compiling

48449 #See \`config.log' for more details." >&2;}

48450 #   { (exit 1); exit 1; }; }; }

48451 else

-------------------------------------------------------------------------------------------------

————————————————

版权声明:本文为CSDN博主「郭老二」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。

原文链接:https://blog.csdn.net/u010168781/article/details/73925118

#由于nercuse库不存在,需要下载编译

root@lsdk:/opt# wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.6.tar.gz

正在上传…重新上传取消

#注意要source setup.env执行环境否则编译出来是gcc而不是mips格式

root@lsdk:/opt/ncurses-5.6# ./configure -prefix=/usr/local/ncurses -with-shared -without-debug --host=mips64el-linux

编译之。

make && make install

#编译完成检查并打包

正在上传…重新上传取消

#继续编译mysql

#缺少lex_hash.h

#缺少STACK_DIRECTION定义

正在上传…重新上传取消

参考:

Ubuntu下编译ARM平台QtEmbedded的MySQL和MySQL插件.docx-原创力文档 (book118.com)

#重点参考

https://blog.csdn.net/u010168781/article/details/73925118

#strip精减大小

root@lsdk:/usr/local/mysql/bin#/opt/offical-loongson/compiler/gcc-4.9.3-64-gnu/bin/mips64el-linux-strip *

  1. 下装mysql的压缩包到开发板测试

#

  1. 初始化

#创建mysql用户组以及用户

sudo groupadd mysql

sudo useradd -g mysql mysql

#源码目录拷贝配置文件

sudo cp support-files/my-medium.cnf /etc/my.cnf

# 进入安装目录

cd /usr/local/mysql5.0.15

#调用初始化脚本进行初始化

sudo ./bin/mysql_install_db --user=mysql

#改变目录所属

sudo chown -R root .

sudo chown -R mysql var

sudo chgrp -R mysql .

  1. 启动MySQL

#设置mysql账号密码

$ sudo passwd mysql

New password:

Retype new password:

passwd: password updated successfully

#切换到mysql账号

$ su mysql

Password:

#进入安装目录

$ cd /usr/local/mysql5.0.15

#启动MySQL

$ ./bin/mysqld_safe --user=mysql &

$ ps aux | grep mysqld

mysql    31960  0.0  0.0   2608  1652 pts/0    S    09:25   0:00 /bin/sh ./bin/mysqld_safe --user=mysql

mysql    31982  0.0  0.4 240132 29508 pts/0    Sl   09:25   0:00 /usr/local/mysql5.0.15/libexec/mysqld --basedir=/usr/local/mysql5.0.15 --datadir=/usr/local/mysql5.0.15/var --pid-file=/usr/local/mysql5.0.15/var/DESKTOP-BQJUB01.pid --skip-locking --port=3306 --socket=/tmp/mysql.sock

  1. 登录MySQL

#设置root用户密码

$ /usr/local/mysql5.0.15/bin/mysqladmin -u root password

#登录

$ /usr/local/mysql5.0.15/bin/mysql -uroot -p123456

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 4 to server version: 5.0.15-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| test               |

+--------------------+

3 rows in set (0.00 sec)

————————————————

版权声明:本文为CSDN博主「happytree001」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。

原文链接:编译MySQL5.0.15_happytree001的博客-CSDN博客

  1. 总结

需要先查configure的帮助。再仔细观察configure.log的日志,一般里面会有比较详细的日志。修改尝试。注意:configure中的环境变量的用法。比如这里就是在前面先生成环境变量传入。典型格式如上述的

#

CXXFLAGS="-std=c++98  -Wno-narrowing " CPPFLAGS="-std=c++98  -Wno-narrowing "  ./configure --prefix=/usr/local/mysql --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=gbk,gb2312 --with-named-curses-libs=/usr/local/ncurses/libncurses.a --host=mips64el-linux

#此处最重要参数—host(交叉编译)和 std=c++98降级模式。还有关闭“编译告警”no-xxx用法

正在上传…重新上传取消

参考资料:https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#Optimize-Options

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值