交叉编译mysql-8.0.22 最新版本

3559A交叉编译mysql-8.0.22 最新版本并运行

Mysql 交叉编译
一、 下载mysql源码包
下载链接:https://downloads.mysql.com/archives/community/

交叉编译mysql-8.0.22 最新版本_第1张图片

选择Generic Linux带boost的版本,这样依赖boost就可以不用另外安装。

二、 Mysql依赖

  1. ncurses
  2. openssl
  3. boost
    每个mysql版本依赖的库版本都不能瞎选,具体可以查询mysql依赖的这三个库的具体版本

三、 安装依赖库
由于boost,下载的mysql包里自带了,所以无需安装。
可以创建一个mysqlbuild文件夹,将mysql、ncurses、openssl包都传进去。

  1. 安装ncurses(路径自己定)
    ./configure --prefix=/home/mysqlbuild/install --host=aarch64-himix100-linux CFLAGS="–sysroot=$SDKTARGETSYSROOT" --without-progs
    Make && make install
  2. 安装openssl
    openssl用3rd-part下的./auto_install_opensrc.sh openssl 直接编译
    前提是修改下open_src_conf.xml下的版本号,并且替换成openssl-1.1.1g

四、 编译mysql

  1. cd mysql-8.0.22
  2. mkdir build
  3. cd build
  4. 执行cmake
    cmake … -LH -DCMAKE_INSTALL_PREFIX=/home/mysqlbuild/mysql-8.0.22/install
    -DMYSQL_DATADIR=/home/mysqlbuild/mysql-8.0.22/install/data
    -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
    -DENABLED_LOCAL_INFILE=1
    -DCMAKE_CXX_COMPILER=/opt/hisi-linux/x86-arm/aarch64-himix100-linux/bin/aarch64-himix100-linux-g++
    -DCMAKE_C_COMPILER=/opt/hisi-linux/x86-arm/aarch64-himix100-linux/bin/aarch64-himix100-linux-gcc
    -DWITH_BOOST=/home/mysqlbuild/mysql-8.0.22/boost/boost_1_73_0
    -DWITH_SSL=/home/mysqlbuild/install
    -DWITH_SASL=/home/mysqlbuild/install
    -DCMAKE_SYSTEM_PROCESSOR=arm
    -DCURSES_INCLUDE_PATH=/home/mysqlbuild/install/include
    -DCURSES_LIBRARY=/home/mysqlbuild/install/lib/libncurses.a
    -DCMAKE_BUILD_TYPE=RELEASE -DWITH_TEST_TRACE_PLUGIN=0 -DIGNORE_AIO_CHECK=1 -DBUILD_CONFIG=mysql_release
    -DWITH_UNIT_TESTS=0
    -DWITH_LIBEVENT=bundled -DEVENT__DISABLE_TESTS=ON -DRESOLV_LIBRARY=/opt/hisi-linux/x86-arm/aarch64-himix100-linux/aarch64-linux-gnu/libc/usr/lib/libresolv.so
  5. 执行make

第一个错
CMake Error at CMakeLists.txt:1374 (MESSAGE):
Please install the patchelf(1) utility.
注释掉cmakefile中的这部分检查

再执行make

第二个错
CMake Error at cmake/libevent.cmake:133 (MESSAGE):
LIBEVENT version must be at least 2.1, found /.l
CMake Error at router/src/http/src/CMakeLists.txt:26 (MESSAGE):
At least version 2.1 is needed for libevent.
自带的libevent版本已经是2.1.11了 将判断的地方直接注释

再执行make
第三个错
/bin/sh: …/runtime_output_directory/uca9dump: cannot execute binary file
make[2]: *** [strings/uca900_zh_tbls.cc] Error 126
这里需要将你编译的x86-64版可执行文件拷贝进来
cp /home/mysqlbuild/mysql-8.0.22pc/mysql-8.0.22/runtime_output_directory/uca9dump /home/mysqlbuild/mysql-8.0.22/build/runtime_output_directory/

再make
第四个错
/home/mysqlbuild/mysql-8.0.22/build/router/src/json_schema_embedder/json_schema_embedder: cannot execute binary file
同理将你编译的x86-64版可执行文件拷贝进来
cp /home/mysqlbuild/mysql-8.0.22pc/mysql-8.0.22/router/src/json_schema_embedder/json_schema_embedder /home/mysqlbuild/mysql-8.0.22/build/router/src/json_schema_embedder/

再make
第五个错
/home/mysqlbuild/mysql-8.0.22/build/runtime_output_directory/comp_sql: cannot execute binary file
同理将你编译的x86-64版可执行文件拷贝进来
cp /home/mysqlbuild/mysql-8.0.22pc/mysql-8.0.22/runtime_output_directory/comp_sql /home/mysqlbuild/mysql-8.0.22/build/runtime_output_directory/

再make
第六个错
…/runtime_output_directory/gen_lex_token: cannot execute binary file
同理将你编译的x86-64版可执行文件拷贝进来
cp /home/mysqlbuild/mysql-8.0.22pc/mysql-8.0.22/runtime_output_directory/gen_lex_token /home/mysqlbuild/mysql-8.0.22/build/runtime_output_directory/

再make
第七个错
…/runtime_output_directory/gen_lex_hash: cannot execute binary file
同理将你编译的x86-64版可执行文件拷贝进来
cp /home/mysqlbuild/mysql-8.0.22pc/mysql-8.0.22/runtime_output_directory/gen_lex_hash /home/mysqlbuild/mysql-8.0.22/build/runtime_output_directory/

再make
第八个错
…/runtime_output_directory/comp_err: cannot execute binary file
同理将你编译的x86-64版可执行文件拷贝进来
cp /home/mysqlbuild/mysql-8.0.22pc/mysql-8.0.22/runtime_output_directory/comp_err /home/mysqlbuild/mysql-8.0.22/build/runtime_output_directory/

再make
第九个错
…/runtime_output_directory/comp_client_err: cannot execute binary file
同理将你编译的x86-64版可执行文件拷贝进来
cp /home/mysqlbuild/mysql-8.0.22pc/mysql-8.0.22/runtime_output_directory/comp_client_err /home/mysqlbuild/mysql-8.0.22/build/runtime_output_directory/

再make
第十个错
…/runtime_output_directory/gen_keyword_list: cannot execute binary file
同理将你编译的x86-64版可执行文件拷贝进来
cp /home/mysqlbuild/mysql-8.0.22pc/mysql-8.0.22/runtime_output_directory/gen_keyword_list /home/mysqlbuild/mysql-8.0.22/build/runtime_output_directory/

再make
第十一个错
/bin/sh: …/…/…/…/runtime_output_directory/protoc: cannot execute binary file
同理将你编译的x86-64版可执行文件拷贝进来
cp /home/mysqlbuild/mysql-8.0.22pc/mysql-8.0.22/runtime_output_directory/protoc /home/mysqlbuild/mysql-8.0.22/build/runtime_output_directory/

再make
第十二个错
/bin/sh: …/runtime_output_directory/libmysql_api_test: cannot execute binary file
同理将你编译的x86-64版可执行文件拷贝进来
cp /home/mysqlbuild/mysql-8.0.22pc/mysql-8.0.22/runtime_output_directory/libmysql_api_test /home/mysqlbuild/mysql-8.0.22/build/runtime_output_directory/

再make
第十二个错
/home/mysqlbuild/mysql-8.0.22/build/runtime_output_directory/xprotocol_plugin: program not found or is not executable
同理将你编译的x86-64版可执行文件拷贝进来
cp /home/mysqlbuild/mysql-8.0.22pc/mysql-8.0.22/runtime_output_directory/xprotocol_plugin /home/mysqlbuild/mysql-8.0.22/build/runtime_output_directory/

再make
第十三个错
/home/mysqlbuild/mysql-8.0.22/storage/innobase/include/os0atomic.ic:194:2: error: #error “Unsupported platform”
这个需要添加一个宏 HAVE_ATOMIC_BUILTINS ,在storage/innobase/include/os0atomic.h中
交叉编译mysql-8.0.22 最新版本_第2张图片
在 mysql-5.7.30/storage/innobase/include/os0atomic.ic
在这里插入图片描述
再make
第十四个错
/usr/lib64/libresolv.so: error adding symbols: File in wrong format
这里再cmake的地方加个
-DRESOLV_LIBRARY=/opt/hisi-linux/x86-arm/aarch64-himix100-linux/aarch64-linux-gnu/libc/usr/lib/libresolv.so
要使用交叉编译工具链里的libresolv.so

再make
第十五个错
/home/mysqlbuild/mysql-8.0.22/storage/innobase/lock/lock0lock.cc:1228:68: error: ‘os_compare_and_swap_thread_id’ was not declared in this scope
出现这个报错的地方 均将os_compare_and_swap_thread_id改成os_compare_and_swap_lint

再make
make成功,将build下的bin 和 share目录拷贝到3559a环境

执行./mysqld 看下是否能执行成功
报错如下:
缺少libprotobuf-lite.so.3.11.4
再将libprotobuf-lite.so.3.11.4拷贝到lib64下,创建个软链接
然后再ldd mysqld 下
交叉编译mysql-8.0.22 最新版本_第3张图片
这里已经正常了

后面就是mysqld 后面跟具体参数的问题了,经过反复尝试后,发现如下命令可以正常启动
./mysqld --basedir=/usr/local/mysql --datadir=/home/rundir/mysql/data --plugin-dir=/home/rundir/arm_build/install/lib/plugin --user=mysql --innodb-flush-method=O_DIRECT --skip-ssl --auto-generate-certs=FALSE --skip-sha256-password-auto-generate-rsa-keys --log-error=/home/rundir/mysql/data/mysqld_safe.log --pid-file=/home/rundir/mysql/data/mysql.pid --innodb_force_recovery=0 --admin-ssl=FALSE --caching-sha2-password-auto-generate-rsa-keys=FALSE &

你可能感兴趣的:(c++)