← Back to team overview

maria-discuss team mailing list archive

Re: Cross compile issue

 

Dear Sergei,

A little understand but not totally.
My native compile directory is "/home/johnson/SanSoft/model/Phoenix_130313/Package/mariadb/native" using "make import_executables"
The below is my cross.cmake file content,
  SET(CMAKE_SYSTEM_NAME Linux)
  SET(CMAKE_SYSTEM_PROCESSOR x86_64)
  SET(STACK_DIRECTION 1)
  SET(CMAKE_C_COMPILER   /home/johnson/x86_64_TCglibc-2.19-3/usr/bin/x86_64-buildroot-linux-gnu-gcc)
  SET(CMAKE_CXX_COMPILER /home/johnson/x86_64_TCglibc-2.19-3/usr/bin/x86_64-buildroot-linux-gnu-g++)
  SET(CMAKE_FIND_ROOT_PATH  /home/johnson/SanSoft/model/Phoenix_130313/build/sysroot)
  SET(IMPORT_EXECUTABLES  /home/johnson/SanSoft/model/Phoenix_130313/Package/mariadb/native)
  SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
  SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
  SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

My configure command is listed as below,
PATH=/home/johnson/x86_64_TCglibc-2.19-3/usr/bin/:/bin:/sbin:/usr/bin:/usr/sbin AR=/home/johnson/x86_64_TCglibc-2.19-3/usr/bin/x86_64-buildroot-linux-gnu-ar AS=/home/johnson/x86_64_TCglibc-2.19-3/usr/bin/x86_64-buildroot-linux-gnu-as LD=/home/johnson/x86_64_TCglibc-2.19-3/usr/bin/x86_64-buildroot-linux-gnu-ld NM=/home/johnson/x86_64_TCglibc-2.19-3/usr/bin/x86_64-buildroot-linux-gnu-nm CC=/home/johnson/x86_64_TCglibc-2.19-3/usr/bin/x86_64-buildroot-linux-gnu-gcc GCC=/home/johnson/x86_64_TCglibc-2.19-3/usr/bin/x86_64-buildroot-linux-gnu-gcc CXX=/home/johnson/x86_64_TCglibc-2.19-3/usr/bin/x86_64-buildroot-linux-gnu-g++ RANLIB=/home/johnson/x86_64_TCglibc-2.19-3/usr/bin/x86_64-buildroot-linux-gnu-ranlib \
                CFLAGS="-I/home/johnson/cross_prj/sysroot/usr/include -I/home/johnson/cross_prj/sysroot/include" \
                CXXFLAGS="-I/home/johnson/cross_prj/sysroot/usr/include -I/home/johnson/cross_prj/sysroot/include" \
                LDFLAGS="-L/home/johnson/cross_prj/sysroot/lib -L/home/johnson/cross_prj/sysroot/usr/lib -lm -lz -ldl -lcrypt -pthread" \
                CXXLDFLAGS="-L/home/johnson/cross_prj/sysroot/lib -L/home/johnson/cross_prj/sysroot/usr/lib -lm -lz -ldl -lcrypt -pthread" \
                ../../cmake/HOST-cmake/bin/cmake ../mariadb-10.0.21 \
                -DCMAKE_TOOLCHAIN_FILE=../cross.cmake

I get two errors about IMPORTFILE-NOTFOUND and XtraDB as below,
  CMake Error at CMakeLists.txt:367 (INCLUDE):
    include could not find load file:

      IMPORTFILE-NOTFOUND


  -- Performing Test HAVE_WVLA
  -- Performing Test HAVE_WVLA - Success
  -- Looking for include file libaio.h
  -- Looking for include file libaio.h - found
  -- Looking for io_queue_init in /home/johnson/SanSoft/model/Phoenix_130313/build/sysroot/usr/lib/libaio.so
  -- Looking for io_queue_init in /home/johnson/SanSoft/model/Phoenix_130313/build/sysroot/usr/lib/libaio.so - found
  -- Looking for sched_getcpu
  -- Looking for sched_getcpu - found
  -- Performing Test HAVE_C99_INITIALIZERS
  -- Performing Test HAVE_C99_INITIALIZERS - Success
  -- Looking for asprintf
  -- Looking for asprintf - found
  -- Check size of pthread_t
  -- Check size of pthread_t - done
  -- Performing Test HAVE_WERROR
  -- Performing Test HAVE_WERROR - Success
  CMake Error at storage/xtradb/CMakeLists.txt:464 (MESSAGE):
    Percona XtraDB is not supported on this platform


  -- Configuring incomplete, errors occurred!

Best Regards,
Johnson

-----Original Message-----
From: Sergei Golubchik [mailto:serg@xxxxxxxxxxx] 
Sent: Thursday, August 27, 2015 3:34 PM
To: Johnson Cheng
Cc: maria-discuss@xxxxxxxxxxxxxxxxxxx
Subject: Re: [Maria-discuss] Cross compile issue

Hi, Johnson!

On Aug 27, Johnson Cheng wrote:
> Dear Sergei,
> 
> Thanks for your reply.
> I am sorry that I can NOT find any document about cross compile from knowledge base.
> https://mariadb.com/kb/en/mariadb/getting-installing-and-upgrading-mar
> iadb/

Yes, that's why I suggested to search the mailing list too. I wasn't sure there's something in the knowledge base :(

> My host machine is Debian5. (gcc version is 4.3.2) My target machine 
> is Intel x86_64 with gcc version is 4.8.3 My Cmake version is 3.2.2 on 
> host machine Here is my cmake command to configure mariadb-10.0.21 for 
> cross compile,
>   PATH=/home/johnson/x86_64_TCglibc-2.19-3/usr/bin/:/bin:/sbin:/usr/bin:/usr/sbin AR=/home/johnson/x86_64_TCglibc-2.19-3/usr/bin/x86_64-buildroot-linux-gnu-ar AS=/home/johnson/x86_64_TCglibc-2.19-3/usr/bin/x86_64-buildroot-linux-gnu-as   LD=/home/johnson/x86_64_TCglibc-2.19-3/usr/bin/x86_64-buildroot-linux-gnu-ld NM=/home/johnson/x86_64_TCglibc-2.19-3/usr/bin/x86_64-buildroot-linux-gnu-nm CC=/home/johnson/x86_64_TCglibc-2.19-3/usr/bin/x86_64-buildroot-linux-gnu-gcc GCC=/home/johnson/x86_64_TCglibc-2.19-3/usr/bin/x86_64-buildroot-linux-gnu-gcc CXX=/home/johnson/x86_64_TCglibc-2.19-3/usr/bin/x86_64-buildroot-linux-gnu-g++ RANLIB=/home/johnson/x86_64_TCglibc-2.19-3/usr/bin/x86_64-buildroot-linux-gnu-ranlib \
>   CFLAGS="-I/home/johnson/ cross_prj /sysroot/usr/include -I/home/johnson/ cross_prj /sysroot/include" \
>   CXXFLAGS="-I/home/johnson/ cross_prj /:sysroot/usr/include -I/home/johnson/ cross_prj /sysroot/include" \
>   LDFLAGS="-L/home/johnson/cross_prj/sysroot/lib -L/home/johnson/ cross_prj /sysroot/usr/lib -lm -lz -ldl -lcrypt -pthread" \
>   CXXLDFLAGS="-L/home/johnson/ cross_prj /sysroot/lib -L/home/johnson/ cross_prj /sysroot/usr/lib -lm -lz -ldl -lcrypt -pthread" \
>   ../../cmake/HOST-cmake/bin/cmake .
> 
> Unfortunately I meet the below error while typing "make VERBOSE=1", [ 
> 15%] Generating ../include/mysqld_error.h.tmp cd 
> /home/johnson/SanSoft/model/Phoenix_130313/Package/mariadb/mariadb-10.
> 0.21/extra && ./comp_err 
> --charset=/home/johnson/SanSoft/model/Phoenix_130313/Package/mariadb/m
> ariadb-10.0.21/sql/share/charsets 
> --out-dir=/home/johnson/SanSoft/model/Phoenix_130313/Package/mariadb/m
> ariadb-10.0.21/sql/share/ 
> --header_file=/home/johnson/SanSoft/model/Phoenix_130313/Package/maria
> db/mariadb-10.0.21/include/mysqld_error.h.tmp 
> --name_file=/home/johnson/SanSoft/model/Phoenix_130313/Package/mariadb
> /mariadb-10.0.21/include/mysqld_ername.h.tmp 
> --state_file=/home/johnson/SanSoft/model/Phoenix_130313/Package/mariad
> b/mariadb-10.0.21/include/sql_state.h.tmp 
> --in_file=/home/johnson/SanSoft/model/Phoenix_130313/Package/mariadb/m
> ariadb-10.0.21/sql/share/errmsg-utf8.txt
> ./comp_err: /lib/libc.so.6: version `GLIBC_2.14' not found (required 
> by ./comp_err)
> ./comp_err: /lib/libc.so.6: version `GLIBC_2.17' not found (required 
> by ./comp_err)
> make[2]: *** [include/mysqld_error.h.tmp] Error 1
> 
> It tries to use my cross compiled extra/comp_err utility to do something at my host machine.

Right...
During the build few helper tools are compiled and used in the build.
See http://www.cmake.org/Wiki/CMake_Cross_Compiling
In particular, we implement the solution from http://www.cmake.org/Wiki/CMake_Cross_Compiling#Using_executables_in_the_build_created_during_the_build

So, you need to build for the native platform first. Not everything, just "import_executables" target:

  make import_executables

This will create import_executables.cmake file. When you cross-compile you'll need to set IMPORT_EXECUTABLES to the path to that file.
 
Regards,
Sergei


Follow ups

References