[cairo] Is there any guide to build cairo for android and ios

Heiko Lewin hlewin at gmx.de
Thu May 7 06:09:18 UTC 2020


You should look into how the build-system you want to use works. I can
only speak for the autotools (configure & make) part using linux.

I found the easiest way to build autotools projects was to setup an
environment for cross-compiling and then executing configure and make as
normal.

This means, you need to set environment-variables for common tools (like
CC for the c-compiler, ....) and then run configure with a --host-argument.

An easy way to do the setup of vars is to write a script to do the
setup. Just to give you an idea which variables you might need I have
attached a script we use at our company. Note this will NOT work for you
out-of-the-box as it depends on other scripts, paths and environment
variables I cannot provide right now.

When all environment is setup you can just run

e.g. configure --host=aarch64-linux-android && make

Seriously - don't ask how to build cairo but have a look at those
build-systems in general. My experience is that once you have a set of
configuration in place you can build most autotools projects without a
hassle.

I'm sorry if this is not all that helpful.


On 5/7/20 5:55 AM, mryangjian wrote:
> Hi,  Is there any guide to build cairo for android and ios.
>
>    The depends library of cairo is more and more, the build system is more and more complicated,   “configure”, “make”, “cmake”, “ninja”, “pkg-config”, “meson” and so on, and much more includes there and here, every library has there own configs, a lot of switch in configs, I must know every one of them before I can build cairo. the android only supported there own make system and cmake, There can found exists guide on the web of build cairo for android is cairo-1.10 about 10 years ago.
>
>    So,  is there any official guide to build cairo for android and ios.
-------------- next part --------------
#!/bin/bash

PLATFORM=$1
PREFIX="${WDY_XBUILD_ROOT}/$PLATFORM"



CONTINUE=true

error() {
  echo $@ > /dev/stderr
  CONTINUE=false
}

if [ -z $WDY_XBUILD_ROOT ]; then
  error "ERROR: WDY_XBUILD_ROOT not set."
fi


if [ $# != 1 ]; then
  error "Usage: android-env (armeabi-v7a|arm64-v8a|x86|x86_64)"
fi


COMMON_CFLAGS="-fdebug-prefix-map=${WDY_XBUILD_ROOT}/src=/src"

case "${PLATFORM}" in
  armeabi-v7a)
	ANDROID_HOST_TRIPLET=armv7a-linux-androideabi21
	export CFLAGS="${CFLAGS} -mfpu=neon"
	export CXXFLAGS="${CXXFLAGS} -mfpu=neon"
    ;;
  arm64-v8a)
	ANDROID_HOST_TRIPLET=aarch64-linux-android21
    ;;
  x86)
	ANDROID_HOST_TRIPLET=i686-linux-android21
    ;;
  x86_64)
	ANDROID_HOST_TRIPLET=x86_64-linux-android21
    ;;
  linux)
	CONTINUE=false
	export ANDROID_ENV_SETUP=true
	export CFLAGS="-Og -g ${COMMON_CFLAGS}"
	export CXXFLAGS="-Og -g ${COMMON_CFLAGS}"
	;;
  *)
    error "Platform '${PLATFORM}' is unknown"
    ;;
esac

HOST_TRIPLET=${ANDROID_HOST_TRIPLET}
export ANDROID_HOST_TRIPLET

export PKG_CONFIG_LIBDIR=${PREFIX}/lib/pkgconfig
export LD_LIBRARY_PATH=${PREFIX}/lib
export LT_SYS_LIBRARY_PATH=${PREFIX}/lib
export LDFLAGS="-Wl,-rpath-link=${PREFIX}/lib"

if [ $CONTINUE = true ]; then
    export ANDROID_HOST_TRIPLET
	export CC=${ANDROID_HOST_TRIPLET}-clang
	export CXX=${ANDROID_HOST_TRIPLET}-clang++
	export LD=${HOST_TRIPLET}-ld
	export AS=${HOST_TRIPLET}-as
	export AR=${HOST_TRIPLET}-ar
	export STRIP=${HOST_TRIPLET}-strip
	export RANLIB=${HOST_TRIPLET}-ranlib
	export CPP="${HOST_TRIPLET}-clang -E"
	export CXXCPP="${HOST_TRIPLET}-clang++ -E"
	export LDFLAGS="${LDFLAGS} -L${PREFIX}/lib -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libunwind.a "
	export CFLAGS="${CFLAGS} -O3 -fexceptions -fPIC -I${PREFIX}/include -g -fno-integrated-as ${COMMON_CFLAGS}"
	export CXXFLAGS="${CXXFLAGS} -O3 -fexceptions -fPIC -I${PREFIX}/include -g -fno-integrated-as ${COMMON_CFLAGS}"
	export CPPFLAGS="${CPPFLAGS} -I${PREFIX}/include"
	export OBJCOPY=${HOST_TRIPLET}-objcopy
	export ANDROID_ENV_SETUP=true
fi






More information about the cairo mailing list