Both libmongoc
and libbson
are automake-based projects now (./configure, make, make install). They additionally install pkg-config *.pc files that can be used to discover library installation and header paths using the pkg-config
program. If you have installed to /usr/local, you might need to set PKG_CONFIG_PATH=/usr/local/lib/pkg-config (or lib64) depending if your system automatically includes that path.
A simple way to build against them is to do:
gcc $(pkg-config --cflags --libs libmongoc-1.0) myfile.c
If you are in a Makefile, you'll need to shell out first. When using GNU make I typically do:
LIBS := $(shell pkg-config --libs libmongoc-1.0)
CFLAGS := $(shell pkg-config --cflags libmongoc-1.0)
DEBUG := -ggdb
OPTS := -O2
WARNINGS := -Wall -Werror
%.o: %.c %.h
$(CC) -o $@ -c $(DEBUG) $(WARNINGS) $(OPTS) $(CFLAGS) $*.c
myprog: myprog.o
$(CC) -o $@ $(DEBUG) $(WARNINGS) $(OPTS) $(LIBS) myprog.o