Iam trying to compile the code example available on the libmosquitto website (at the bottom): http://mosquitto.org/man/libmosquitto-3.html
Iam using Ubuntu 12.04 and
You have to put the -lmosquitto at the end (after the source files).
-lmosquitto
gcc mosquito.c -lmosquitto -o mosquito # or gcc mosquito.c -o mosquito -lmosquitto # or gcc -o mosquito mosquito.c -lmosquitto
Or better:
gcc -Wall -Wextra -pedantic -o mosquito mosquito.c -lmosquitto