CannedCorn said: This works:
gcc myfile.c $(pkg-config --libs --cflags libcurl) -o myprogram
But this would be easier to understand maybe?
gcc myfile.c -lcurl -o myprogram
Maybe someone could describe how they are different?
Yes, that would be easier to understand but it hard codes the location of the curl library. It has to be in /usr/lib or /usr/local/lib since those are the default directories where gcc searches for libraries. What if I build the curl library from source and drop it in my home directory? This is the problem that the pkg-config program alleviates. When I build and install curl a pkg-config file is built based on where I installed curl then any other program can reference that file in order to include the headers or link to the libraries.
Hope this clarifies things a little.