meson 工具使用 glib-2.68.1交叉编译

安装python3.7

1.安装依赖

sudo apt-get install -y gcc make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev git gperf ddbus libdbus-glib-1-dev

 2.下载python源码 Python-3.7.10.tar.xz

./configure 

make 

sudo make install

安装 meson 

pip3 install --user meson

安装 ninja

pip3 install --user ninja

meson手册 Manual

编译glib项目


#!/bin/bash
set -e

DEVEL=/home/username/build_root/devel

if [ -d _build ];then
rm -r _build
fi
mkdir _build

arch='arm-linux-gnueabi-'
sys_root='/home/username/build_root/devel'
#创建交叉编译配置文件cross_file.txt

#还可设置c_args等等类似 CFLAGS
echo "[constants]" > cross_file.txt
echo "arch = '${arch}'" >> cross_file.txt
echo "[binaries]" >> cross_file.txt
echo "c = arch + 'gcc'" >> cross_file.txt
echo "cpp = arch + 'g++'" >> cross_file.txt
echo "ar = arch + 'ar'" >> cross_file.txt
echo "ld = arch + 'ld'" >> cross_file.txt
echo "srtip = arch + 'strip'" >> cross_file.txt
echo "sys_root = '${sys_root}'" >> cross_file.txt
echo "pkg_config_libdir = '${sys_root}/usr/lib/pkgconfig'" >> cross_file.txt

#编译结果可运行平台的架构
echo "[host_machine]" >> cross_file.txt
echo "system = 'linux'" >> cross_file.txt
echo "cpu_family = 'arm'" >> cross_file.txt
echo "cpu = 'armv7hl'" >> cross_file.txt
echo "endian = 'little'" >> cross_file.txt

#类似于configure功能 meson configure 获取到可配置项
echo "[project options]" >> cross_file.txt
echo "prefix = '/usr'" >> cross_file.txt
echo "selinux = 'disabled'" >> cross_file.txt
echo "libelf = 'disabled'" >> cross_file.txt

#类似于执行configure
meson setup _build --cross-file cross_file.txt
cd _build
#编译 类似于make
ninja
cd ../ 
#类似于make install DESTDIR=$DEVEL
DESTDIR=$DEVEL meson install

你可能感兴趣的:(编程语言,linux)