How to resolve : undefined reference to `pcap_lookupdev’

If you are trying to compile any network packet capturing related program, there are higher chances you may see an errors like,

undefined reference to `pcap_lookupdev'
undefined reference to `pcap_open_live'
undefined reference to `pcap_loop'
undefined reference to `pcap_geterr'
collect2: error: ld returned 1 exit status

This error is because, you either doesn’t have libpcap installed or its not being linked from the command line. Lets say you are trying to compile simple wifi packet sinffer based on libpcap, then first you will need to install libpcap.

 $ sudo apt-get install libpcap-dev 

This will install your machine dependent libpcap version. and then link the libpcap during compilation as,

 $ gcc -o simplesniffer simplesniffer.c -lcap 
Android Android Build system Android Commands Android Java Applications Application Libraries Application Stack / User Interface Bash / Shell Scripts Commands and Packages Compilation Content Management System - CMS Core Kernel C Programs Development & Build Development Environment Setup Errors & Failures git Go Language Programs Hardware Platforms HTML JAVA Programs Kernel & Device Drivers Kernel Booting and Porting Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Monetization / Google AdSense NDK / Middleware / HAL OS Concepts PHP Programming Languages RaspberryPi Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Socurce Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Userspace Utilities Web design and development Wordpress Yocto / Bitbake / Openembedded

Leave a Reply / Ask Question