I am trying to add the pcap library to my application. I need to add it to the configure.ac
file, but I don't understand how.
Can anyone can help me with this?
The standard way to check if a library exists and to link against it is to use AC_CHECK_LIB
. For example:
AC_CHECK_LIB([pcap],[pcap_create])
You should also check for the headers:
AC_CHECK_HEADERS([pcap/pcap.h])
There is a school of thought that argues for using PKG_CHECK_MODULES
, but that is not necessary. Just adding AC_CHECK_LIB
will enable a well configured system to build your package. Glancing at an old version of the libpcap source, I see that libpcap does the correct thing and does not provide a *.pc file, so PKG_CHECK_MODULES
is not an option in your case, and you can safely ignore this paragraph.