It is compulsory to use -lpcap with gcc to compile libpcap program, but I don't know what this flag means. Can anybody help me??
Example:
$ gcc lpcap_demo.c -o lpcap_output.o -lpcap
Thank you!!!
It is compulsory to use -lpcap with gcc to compile libpcap program, but I don't know what this flag means. Can anybody help me??
Example:
$ gcc lpcap_demo.c -o lpcap_output.o -lpcap
Thank you!!!
gcc -l
instructs GCC to link the program with the library given as command-line option, and pcap
is the name of libpcap
. The lib
prefix of the library name is implied, so if you were to write -lpthread
you would link with libpthread
, a POSIX thread library, -lrt
links with librt
, which is a real time extension library and so on and so forth :)
So yeah, it is compulsory to compile with -lpcap
as long as you are using exported symbols from the pcap library.
Does this answer your question? :)
You can get more information by typing this command in the terminal:
man gcc
... and search for the -l
option.
Here is the man page on GCC :