c++cmakefilemongo-c-driver

how to add pkg-config to a Makefile?


My Makefile looks like this :

all:main.cpp
    g++ -I../../DrAPI/ -Wl,--no-as-needed -ldl -lrt -o SampleApp01 $< 
clean:
    rm -f SampleApp01

this is what I would do without Makefile:

gcc main.cpp -o test $(pkg-config --cflags --libs libmongoc-1.0)

now because of importing DrAPI I have to use Makefile to include that API as well, but I would lose libmongoc-1.0 without pkg-config. In that case, how should I add $(pkg-config --cflags --libs libmongoc-1.0) into my Makefile so that it works?


Solution

  • all:main.cpp g++ -I../../DrAPI/ `pkg-config --cflags --libs libmongoc-1.0` -Wl,--no-as-needed -ldl -lrt -o SampleApp01 $< clean: rm -f SampleApp01