如何使用 android ndk 编译 glib 2.66 with meson?
How to use android ndk to compile glib 2.66 with meson?
环境:
编译器:android-ndk-r21b,api24
Ubuntu 20.04
能说会道 2.66
我已经构建了 iconv,并成功地使用 make 构建了 glib 2.56,现在我尝试使用介子构建 glib 2.66,我构建了 运行 这个脚本:
OUTDIR=$HOME/work/ndk/builddir/out
CC=arm-linux-androideabi-gcc CFLAGS="-L$OUTDIR/lib -I$OUTDIR/include" LDFLAGS="-L$OUTDIR/lib" LIBS="-liconv" CXXFLAGS="-L$OUTDIR/lib" meson release/ \
--cross-file cross_file.txt \
--prefix=$OUTDIR \
但是编译错误:
Header <iconv.h> has symbol "iconv_open" : YES
meson.build:1930:4: ERROR: C shared or static library 'iconv' not found
A full log can be found at /home/git/work/ndk/builddir/glib-2.66.4/reconfigure/meson-logs/meson-log.txt
cross_file.txt:
[host_machine]
system = 'android'
cpu_family = 'arm'
cpu = 'arm'
endian = 'little'
[constants]
android_ndk = '/home/git/work/ndk/toolchain/bin/'
toolchain = '/home/git/work/ndk/toolchain/bin/arm-linux-androideabi-'
outdir = '/home/git/work/ndk/builddir/out/'
[binaries]
c = android_ndk + 'arm-linux-androideabi-gcc'
cpp = android_ndk + 'arm-linux-androideabi-g++'
ar = android_ndk + 'arm-linux-androideabi-ar'
ld = android_ndk + 'arm-linux-androideabi-ld'
c_ld = android_ndk + 'arm-linux-androideabi-ld'
objcopy = android_ndk + 'arm-linux-androideabi-objcopy'
strip = android_ndk + 'arm-linux-androideabi-strip'
pkgconfig = '/usr/bin/pkg-config'
[built-in options]
c_std = 'c11'
libdir = '/home/git/work/ndk/builddir/out/lib'
prefix = '/home/git/work/ndk/builddir/out/'
c_args = ['-L/home/git/work/ndk/builddir/out/lib', '-I/home/git/work/ndk/builddir/out/include']
cpp_args = ['-L/home/git/work/ndk/builddir/out/lib', '-I/home/git/work/ndk/builddir/out/include']
c_link_args = ['-I/home/git/work/ndk/builddir/out/include', '-L/home/git/work/ndk/builddir/out/lib']
pkg_config_path = '/home/git/work/ndk/builddir/out/lib/pkgconfig'
我明白了。我不应该设置 c_ld
变量。 gio 的介子脚本中有一个错误,所以我必须在 ubuntu 上删除 libelf-dev(或修改 gio/meson.build)。
访问我的 github 获取配置文件:
https://github.com/edaplayer/android-ndk-harfbuzz/blob/main/glib-2.66.4/build_glib_meson.sh
https://github.com/edaplayer/android-ndk-harfbuzz/blob/main/glib-2.66.4/cross_file.txt
环境:
编译器:android-ndk-r21b,api24
Ubuntu 20.04
能说会道 2.66
我已经构建了 iconv,并成功地使用 make 构建了 glib 2.56,现在我尝试使用介子构建 glib 2.66,我构建了 运行 这个脚本:
OUTDIR=$HOME/work/ndk/builddir/out
CC=arm-linux-androideabi-gcc CFLAGS="-L$OUTDIR/lib -I$OUTDIR/include" LDFLAGS="-L$OUTDIR/lib" LIBS="-liconv" CXXFLAGS="-L$OUTDIR/lib" meson release/ \
--cross-file cross_file.txt \
--prefix=$OUTDIR \
但是编译错误:
Header <iconv.h> has symbol "iconv_open" : YES
meson.build:1930:4: ERROR: C shared or static library 'iconv' not found
A full log can be found at /home/git/work/ndk/builddir/glib-2.66.4/reconfigure/meson-logs/meson-log.txt
cross_file.txt:
[host_machine]
system = 'android'
cpu_family = 'arm'
cpu = 'arm'
endian = 'little'
[constants]
android_ndk = '/home/git/work/ndk/toolchain/bin/'
toolchain = '/home/git/work/ndk/toolchain/bin/arm-linux-androideabi-'
outdir = '/home/git/work/ndk/builddir/out/'
[binaries]
c = android_ndk + 'arm-linux-androideabi-gcc'
cpp = android_ndk + 'arm-linux-androideabi-g++'
ar = android_ndk + 'arm-linux-androideabi-ar'
ld = android_ndk + 'arm-linux-androideabi-ld'
c_ld = android_ndk + 'arm-linux-androideabi-ld'
objcopy = android_ndk + 'arm-linux-androideabi-objcopy'
strip = android_ndk + 'arm-linux-androideabi-strip'
pkgconfig = '/usr/bin/pkg-config'
[built-in options]
c_std = 'c11'
libdir = '/home/git/work/ndk/builddir/out/lib'
prefix = '/home/git/work/ndk/builddir/out/'
c_args = ['-L/home/git/work/ndk/builddir/out/lib', '-I/home/git/work/ndk/builddir/out/include']
cpp_args = ['-L/home/git/work/ndk/builddir/out/lib', '-I/home/git/work/ndk/builddir/out/include']
c_link_args = ['-I/home/git/work/ndk/builddir/out/include', '-L/home/git/work/ndk/builddir/out/lib']
pkg_config_path = '/home/git/work/ndk/builddir/out/lib/pkgconfig'
我明白了。我不应该设置 c_ld
变量。 gio 的介子脚本中有一个错误,所以我必须在 ubuntu 上删除 libelf-dev(或修改 gio/meson.build)。
访问我的 github 获取配置文件:
https://github.com/edaplayer/android-ndk-harfbuzz/blob/main/glib-2.66.4/build_glib_meson.sh
https://github.com/edaplayer/android-ndk-harfbuzz/blob/main/glib-2.66.4/cross_file.txt