嵌入式开发:交叉编译与引导加载器全解析
1. 交叉编译中的包配置
在软件开发中,跟踪包依赖是一项复杂的任务。 pkg-config
工具(https://www.freedesktop.org/wiki/Software/pkg-config/)可以帮助我们跟踪已安装的包以及每个包所需的编译标志。它通过在 [sysroot]/usr/lib/pkgconfig
中维护一个 Autotools 包的数据库来实现这一功能。
例如,SQLite3 的包配置文件名为 sqlite3.pc
,其中包含了其他需要使用它的包所需的基本信息:
$ cat $(arm-cortex_a8-linux-gnueabihf-gcc -print-sysroot)/usr/lib/pkgconfig/sqlite3.pc
# Package Information for pkg-config
prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: SQLite
Description: SQL database engine
Version: 3.33.0
Libs: -L${libdir} -lsqlite3
Libs.private: -lm -ldl -lpthread
Cflags: -I${includedir}
我们可以使用 pkg-config