如何为 Raspberry Pi 应用程序 link libconfig 库

How to link libconfig library for Raspberry Pi application

目前,我正在修改 Raspberry Pi 的 C 应用程序。 我使用此命令构建应用程序:

make

现在我想使用 libconfig 库。 我有以下问题

pi@raspberrypi ~/yyyyy $ make
make --no-print-directory all-am
  CC       tools/xxxxx.o
  CCLD     tools/xxxxx
tools/xxxxx.c:2434: undefined reference to `config_read_file'
tools/xxxxx.c:2441: undefined reference to `config_lookup_string'
tools/xxxxx.c:2446: undefined reference to `config_destroy'
tools/xxxxx.c:2436: undefined reference to `config_destroy'

libconfig manual 他们说:

To link with the library, specify ‘-lconfig’ as an argument to the linker.

如何使用 make 命令 link?

无需研究 bluez 的构建系统,我可以提供简单的方法 - 使用环境变量。

# export CPPFLAGS='-I/home/oleksandr/software/libconfig/include'
# export LDFLAGS='-L/home/oleksandr/software/libconfig/lib/'
# ./configure

这应该会生成 Makefile,您可以使用它来编译 bluez 并link它与 libconfig。