I am trying to link a Library to my C program but I can't make it work
according to the library doc https://jansson.readthedocs.io/en/latest/gettingstarted.html#compiling-and-installing-jansson all I have to do is put
pkg-config --cflags --libs jansson
after GCC in the Makefile, but I get the following error :
make -C pkg-config --cflags --libs jansson
src
make: invalid option -- '/'
make: invalid option -- 'u'
make: invalid option -- '/'
Usage: make [options] [target] ...
Inside your Makefile do something like this:
LIBS = $(shell pkg-config --libs jansson)
CFLAGS = $(shell pkg-config --cflags jansson)
Then, inside your targets (where you compile/link your code) use it following way:
cc ... $(LIBS) $(CFLAGS)
If you are looking for Makefile
sample, take a look here:
http://www.owsiak.org/fortran-and-gnu-make/
It is not exactly what you are looking for, but it should give you some ideas about Makefile
structure, targets, wildcards, etc. It's Fortran
based, but I am pretty sure you can easily read it.