【Linux】第三章 移植开源库

在开始移植前,默认已经下载好库文件并解压好

移植三部曲:

./configuer : 配置参数
make : 编译
make install : 安装

 

configure 配置参数说名

1 说明

在linux 中,经常需要用到交叉编译,在ubuntu系统中,交叉编译可以运行在arm平台上的bin文件。对于大部分代码,
都有configure文件,让开发者进行配置,配置完毕之后自动生成makefile,然后进行编译。本文旨在说明configure中
常用的一些参数。

2 开发环境

软件环境: ubuntu 操作系统
编译工具链:arm-openwrt-linux
硬件平台:高通ipq

3 configure参数说明

3.1 查看configure 配置选项

在configure目录下,运行 ./configure --help 命令,可以查看到configure的配置参数一共有哪些。

3.2 参数说明

3.2.1 build 参数 : 执行代码编译的主机,可以默认不写

--build=BUILD     configure for building on BUILD [guessed]

 

3.2.2 host 参数 : 指定软件运行的系统平台

--host=HOST       cross-compile to build programs to run on HOST [BUILD]

例如 arm-openwrt-linux 这个平台时:

--host=arm-openwrt-linux

3.2.3 target 参数 : 建立交叉编译环境,一般可不填,如果填写,和 host 保持一致

--target=TARGET   configure for building compilers for TARGET [HOST]

3.2.4 CC 参数 : 交叉编译器命令

CC          C compiler command

举例:

CC=arm-openwrt-linux-muslgnueabi-gcc

3.2.5 prefix 参数 :指定编译 make install 后,文件安装的目录

 --program-prefix=PREFIX            prepend PREFIX to installed program names
注:不指定prefix,则可执行文件默认放在/usr/local/bin,库文件默认放在/usr/local/lib,配置文件默认放在/usr/local/etc。其他的资源文件放在/usr/local/share
--prefix=/home/tmp/test

3.3 编译参数示例

./configure --target=arm-openwrt-linux --host=arm-openwrt-linux --build=x86_64-linux-gnu --prefix=/usr
或者
./configure --host=arm-openwrt-linux  --build=x86_64-linux-gnu
或者
./configure  --host=arm-openwrt-linux

 链接:用 Makefile 处理库移植

猜你喜欢

转载自www.cnblogs.com/vx-cg248805770/p/11814016.html
今日推荐