![](https://secure.gravatar.com/avatar/c28aec97abcd925407437e8418302fdb.jpg?s=120&d=mm&r=g)
Dear All, SOLVED. I share my final solution here, and hope it can help more people in the future. Prerequisite packages: (I list the dependency packages with my version) cmake 3.22 ncurses 5.5 zlib 1.2.8 pcre 8.37 The content of my cross.cmake file: SET(CMAKE_SYSTEM_NAME Linux) SET(CMAKE_SYSTEM_PROCESSOR x86_64) SET(STACK_DIRECTION -1) SET(HAVE_IB_GCC_ATOMIC_BUILTINS 1) SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) Steps to cross compile mariadb-10.0.21: 1. Untar mariadb-10.0.21 # mkdir mariadb # cd mariadb && tar zxvf mariadb-10.0.21.tar.gz 2. build host utility # mkdir native # cd native && /home/johnson/cmake/HOST-cmake/bin/cmake ../mariadb-10.0.21 # make import_executables 3. Patch storage/connect/filamvct.cpp and storage/connect/tabvct.cp, otherwise you will have trouble on Linux 3.14.x during cross-compiling because the prototype is not the same. Comment out strerror definition as below, //char *strerror(int num); 4. cross compile # mkdir cross # CFLAGS="-I/home/johnson/cross_prj/sysroot/include -I/home/johnson/cross_prj/sysroot/usr/include" \ CXXFLAGS="-I/home/johnson/cross_prj/sysroot/include -I/home/johnson/cross_prj/sysroot/usr/include" \ LDFLAGS="-L/home/johnson/cross_prj/sysroot/lib -L/home/johnson/cross_prj/sysroot/usr/lib" \ CXXLDFLAGS="-L/home/johnson/cross_prj/sysroot/lib -L/home/johnson/cross_prj/sysroot/usr/lib" \ /home/johnson/cmake/HOST-cmake/bin/cmake ../mariadb-10.0.21 \ -DCMAKE_TOOLCHAIN_FILE=../cross.cmake \ -DCMAKE_C_COMPILER=/home/johnson/x86_64_TCglibc-2.19-3/usr/bin/x86_64-buildroot-linux-gnu-gcc \ -DCMAKE_CXX_COMPILER=/home/johnson/x86_64_TCglibc-2.19-3/usr/bin/x86_64-buildroot-linux-gnu-g++ \ -DIMPORT_EXECUTABLES=/home/johnson/mariadb/native/import_executables.cmake \ -DCMAKE_FIND_ROOT_PATH=/home/johnson/cross_prj/sysroot # make Trouble shooting: 1. If you have problem on DB_TXN that no member named set_client_id during cross-compiling Maybe it’s conflict with berkeleyDB data structure. You can modify berkeleyDB installed path to /home/johnson/cross_prj/sysroot/usr/local. 2. If you have problem on pcre_stack_guard that not declared during cross-compiling, I suspect that your native system pcre is 8.34 or later and your cross-compilation pcre is older. You can upgrade your pcre version to 8.37. It's OK on my environment. Finally, thanks for the help of Sergei. Best Regards, Johnson -----Original Message----- From: Johnson Cheng Sent: Sunday, September 06, 2015 4:37 PM To: 'Sergei Golubchik' Cc: maria-discuss@lists.launchpad.net Subject: RE: [Maria-discuss] Cross compile issue Dear Sergei, After spent a lot of time on try-and-error method, I find out a solution. This issue happened because it conflicts to berkeleyDB db.h and db_cxx.h include files, so you just remove these two files before cross compiling mariaDB. It's work but this is not my solution. Because my mariaDB include path is set to sysroot/include and sysroot/usr/include, and my berkeleyDB installed path is also set to "sysroot/usr" (sysroot/usr/include, sysroot/usr/lib/, ..), I just correct my berkeleyDB installed path from "sysroot/usr" to "sysroot/usr/local". It can solve data structure conflict issue between berkeleyDB and mariaDB, like DB_TXN ... Best Regards, Johnson -----Original Message----- From: Sergei Golubchik [mailto:serg@mariadb.org] Sent: Thursday, September 03, 2015 9:00 PM To: Johnson Cheng Cc: maria-discuss@lists.launchpad.net Subject: Re: [Maria-discuss] Cross compile issue Hi, Johnson! On Sep 03, Johnson Cheng wrote:
Dear Sergei,
Thanks for your reply. I am not sure what it happened because it is disappeared when I re-cross-compile mariaDB at another new environment. Actually I am dig out a problem about DB_TXN error message as below, [ 80%] Building CXX object storage/tokudb/CMakeFiles/tokudb.dir/ha_tokudb.cc.o In file included from /home/johnson/SanSoft/model/Phoenix_130313-0901/Package/maria/mariadb-10.0.21/storage/tokudb/ha_tokudb.cc:122:0: /home/johnson/SanSoft/model/Phoenix_130313-0901/Package/maria/mariadb-10.0.21/storage/tokudb/hatoku_defines.h: In function int txn_begin(DB_ENV*, DB_TXN*, DB_TXN**, uint32_t, THD*): /home/johnson/SanSoft/model/Phoenix_130313-0901/Package/maria/mariadb-10.0.21/storage/tokudb/hatoku_defines.h:407:19: error: DB_TXN has no member named ‘set_client_id this_txn->set_client_id(this_txn, thd_get_thread_id(thd)); ^ Fortunately, I find out the root cause because I have installed BerkeleyDB at first. It seems mariaDB and BerkeleyDB can't co-exist.
Yes, TokuDB uses uses data types with the same name. But they can coexist (they do on my laptop), so that must be something related to cross compilation again, may be cmake gets include paths incorrectly...
Now I can cross compile mariaDB every time, and I am doing the final fine tune.
Congrats! Regards, Sergei