Ubuntu 16.04 下 Android Native Libs 交叉编译

本文最后更新于:May 7, 2023 pm

[TOC]

CImg for Android

Add the following code in CImg.h from https://github.com/dtschump/CImg.git to NOT use Xlib.h:

1
2
#undef cimg_display
#define cimg_display 0

build OpenCV for Android

  • https://blog.csdn.net/u011178262/article/details/78209791#for_Android_127

build Suitsparse for Android

  • https://github.com/cggos/suitesparse_for_android

build Google Ceres-Solver for Android

ceres-solver-1.14.0

ref: How to Compile Ceres Android Library with NDK under Mac

替换 ceres-solver-1.14.0/jniApplication.mk 中的内容为

1
2
3
4
5
6
7
8
APP_BUILD_SCRIPT := $(call my-dir)/Android.mk
APP_PROJECT_PATH := $(call my-dir)

APP_CPPFLAGS := -frtti -fexceptions -std=c++0x
APP_OPTIM := release

APP_STL := gnustl_static
APP_ABI := armeabi-v7a

ceres-solver-1.14.0/jni

1
EIGEN_PATH=/home/cg/projects/3rdparty/eigen-3.3.7 ndk-build -j1

编译完后,在 ceres-solver-1.14.0/obj/local/armeabi-v7a 下生成 libceres.a 文件。

build FFTW for Android

It is best to download official tarballs from http://fftw.org/, other than using its github repository!!!

Build Reference: fftw_android( from he-kai github )

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/sh
set -o errexit

# Compiles fftw3 for Android
# Make sure you have ANDROID_NDK defined in .bashrc or .bash_profile

PROJECT_ROOT="`pwd`/../"
INSTALL_DIR="$PROJECT_ROOT/jni/ndk-modules/fftw3"
mkdir -p $INSTALL_DIR

NDK_DIR=${ANDROID_NDK}

export PATH="$NDK_DIR/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/:$PATH"
export SYS_ROOT="$NDK_DIR/platforms/android-9/arch-arm/"
export CC="arm-linux-androideabi-gcc --sysroot=$SYS_ROOT"
export CXX="arm-linux-androideabi-g++"
export LD="arm-linux-androideabi-ld"
export AR="arm-linux-androideabi-ar"
export RANLIB="arm-linux-androideabi-ranlib"
export STRIP="arm-linux-androideabi-strip"
export CFLAGS="-mfpu=neon -march=armv7-a -mfloat-abi=softfp" #use Thumb-2 instructs
export CXXFLAGS="-lstdc++"
export LDFLAGS="-lc -lgcc"

SRC_DIR="./fftw-3.3.3"
cd $SRC_DIR

##### configure & make & make install #####

./configure --host=arm-eabi --prefix=$INSTALL_DIR --enable-float --enable-neon

make -j$(nproc)
make install -j$(nproc)

exit 0

Ubuntu 16.04 下 Android Native Libs 交叉编译
https://cgabc.xyz/posts/f1c44ae/
Author
Gavin Gao
Posted on
August 12, 2020
Licensed under