需要将openssl升级到1.1.1o以上版本,mysql升级到5.7.41以上版本
1、交叉编译openssl 1.1.1w
wget https://www.openssl.org/source/old/1.1.1/openssl-1.1.1w.tar.gz
tar xf openssl-1.1.1w.tar.gz
cd openssl-1.1.1w/
./Configure --prefix=/home/3536_cross shared no-threads --cross-compile-prefix=aarch64-linux-gnu- linux-aarch64
make -j4
make install
2、交叉编译boost
下载地址 https://sourceforge.net/projects/boost/files/boost/1.59.0/
tar xf boost_1_59_0.tar.bz2
cd boost_1_59_0/
./bootstrap.sh --prefix=/home/3536_cross
然后修改交叉编译使用的编译器
vi project-config.jam
if ! gcc in [ feature.values <toolset> ]
{
- using gcc ;
+ using gcc : arm : aarch64-linux-gnu-g++ ;
}
编译安装
./bjam
./b2
./b2 install
3、本地编译mysql 5.7.44
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-boost-5.7.44.tar.gz
tar xf mysql-boost-5.7.44.tar.gz
mv mysql-5.7.44 mysql-5.7.44-x86
cd mysql-5.7.44-x86/BUILD/
vi compile-pentium
-cmake $path/.. -DWITH_DEBUG=0
+cmake $path/.. -DWITH_DEBUG=0 -DWITH_BOOST=/home/3536_cross_src/mysql-5.7.44-x86/boost/boost_1_59_0/
./compile-pentium
4、交叉编译mysql 5.7.44
tar xf mysql-boost-5.7.44.tar.gz
mv mysql-5.7.44/ mysql-5.7.44-arm
cd mysql-5.7.44-arm/
mkdir armbuild
cd armbuild/
vi ../CMakeLists.txt
在文件的前面部分加上
SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_PROCESSOR arm)
SET(CMAKE_SYSTEM_VERSION 1)
SET(CMAKE_CROSSCOMPILING 1)
SET(STACK_DIRECTION 1)
# 指定交叉编译gcc的路径
SET(CMAKE_C_COMPILER /opt/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc)
SET(CMAKE_CXX_COMPILER /opt/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-g++)
# 指定源码附带的boost路径
SET(BOOST_INCLUDE_DIR /home/3536_cross_src/mysql-5.7.44-arm/boost/boost_1_59_0/)
# 指定openssl路径
SET(WITH_SSL /home/3536_cross)
# 指定ncurse路径
SET(CURSES_LIBRARY /home/3536_cross/lib/libncurses.a)
SET(CURSES_INCLUDE_PATH /home/3536_cross)
# 指定编译后的安装路径
SET(CMAKE_INSTALL_PREFIX /usr/local/mysql)
5.7系列的mysql,还要修改libevent的cmake文件,跳过测试编译的过程
vi ../cmake/libevent.cmake
- SET(TEST_SRC
- "#include <event.h>
- #include <stdio.h>
- int main()
- {
- fprintf(stdout, \"%s\", LIBEVENT_VERSION);
- }
- "
- )
- FILE(WRITE
- "${CMAKE_BINARY_DIR}/find_libevent_version.c"
- "${TEST_SRC}"
- )
- TRY_RUN(TEST_RUN_RESULT COMPILE_TEST_RESULT
- ${CMAKE_BINARY_DIR}
- "${CMAKE_BINARY_DIR}/find_libevent_version.c"
- CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${LIBEVENT_INCLUDE_DIRS}"
- COMPILE_OUTPUT_VARIABLE OUTPUT
- RUN_OUTPUT_VARIABLE RUN_OUTPUT
- )
+ SET(COMPILE_TEST_RESULT TRUE)
+ SET(RUN_OUTPUT "2.1.11-stable")
开始编译
cmake ../
报错1 /bin/sh: comp_err: command not found
要从x86编译版本中拷贝过来
cp ../../mysql-5.7.44-x86/BUILD/extra/comp_err /usr/local/bin/
报错2 /home/3536_cross_src/mysql-5.7.44-arm/storage/innobase/include/os0atomic.ic:230:2: error: #error "Unsupported platform"
修改/storage/innobase/include/os0atomic.h
#if defined __i386__ || defined __x86_64__ || defined _M_IX86 \
|| defined _M_X64 || defined __WIN__
#define IB_STRONG_MEMORY_MODEL
+#else
+#define HAVE_ATOMIC_BUILTINS
#endif /* __i386__ || __x86_64__ || _M_IX86 || _M_X64 || __WIN__ */
修改/storage/innobase/include/os0atomic.ic
-#elif defined(IB_STRONG_MEMORY_MODEL)
+#elif defined(IB_STRONG_MEMORY_MODEL) || defined (HAVE_ATOMIC_BUILTINS)
报错3 error: ‘os_compare_and_swap_thread_id’ was not declared in this scope
修改/storage/innobase/include/os0atomic.h
-# ifdef HAVE_IB_ATOMIC_PTHREAD_T_GCC
-#if defined(HAVE_GCC_SYNC_BUILTINS)
+# ifdef HAVE_ATOMIC_BUILTINS
+#if defined(HAVE_ATOMIC_BUILTINS)
# define os_compare_and_swap_thread_id(ptr, old_val, new_val) \
os_compare_and_swap(ptr, old_val, new_val)
#else
报错4 No rule to make target '../scripts/comp_sql'
从x86编译版本中拷贝过来
cp ../../mysql-5.7.44-x86/BUILD/scripts/comp_sql ../scripts/
cp ../../mysql-5.7.44-x86/BUILD/scripts/comp_sql /usr/local/bin
报错5 /bin/sh: gen_lex_hash: command not found
/bin/sh: gen_lex_token: command not found
从x86编译版本中拷贝过来
cp /home/3536_cross_src/mysql-5.7.44-x86/BUILD/sql/gen_lex_* /usr/local/bin/
报错6 protoc: command not found
从x86编译版本中拷贝过来
cp /home/3536_cross_src/mysql-5.7.44-x86/BUILD/extra/protobuf/protoc /usr/local/bin/
报错7 Linking CXX executable libmysql_api_test
/lib/ld-linux-aarch64.so.1: No such file or directory
从x86编译版本中拷贝过来
cp ../../mysql-5.7.44-x86/BUILD/libmysql/libmysql_api_test ./libmysql/
报错8 cannot find -lboost_system -lboost_chrono
vi client/dump/CMakeFiles/mysqlpump.dir/link.txt
-lboost_system -lboost_chrono 前面添加 -L/home/3536_cross/lib,就是boost交叉编译时指定的prefix
网友评论