cdebianraspberry-pi2libconfig

How to link libconfig library for Raspberry Pi application


Currently, I am modifying the C application for Raspberry Pi. I build the application with this command:

make

Now I want to use libconfig library. I have this below problems

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'

In the libconfig manual they said:

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

How can I link with make command?


Solution

  • Without looking into bluez's build system, I can offer simple approach - using environment variables.

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

    This should generate you Makefile, which you can use to compile bluez and link it with libconfig.