Cyberithub

[Solved]: "ERROR! Libpcap library/headers not found"

Advertisements

Are you getting "ERROR! Libpcap library/headers not found" on the output while trying to compile and install an application from source code in your system ? Are you looking for solution to fix this error ? Are you worried thinking from where this error came ? If yes, then don't worry. Here we will see how to solve "ERROR! Libpcap library/headers not found" in detail with the help of a recent example I have encountered in my system. But before that let's try to understand what exactly is this error.

As it is self understood from the error itself, it basically means Libpcap library or its headers are not found in the system due to some reasons local to the system. Basically, Libpcap library is a free and open source cross platform library that provides the implementation of the capability to capture packets using functionalities provided by the operating system.

This library is often used by number of applications so well before installing any application it would expect this library and its header files to be preinstalled. During installation, if it doesn't find the libpcap library or its header files then it will throw "ERROR! Libpcap library/headers not found" on the output. If you are also facing this error then I would urge you to follow this article to fix the problem.

 

[Solved]: "ERROR! Libpcap library/headers not found"

[Solved]: "ERROR! Libpcap library/headers not found"

Also Read: How to Install jq(JSON processor) on Ubuntu 22.04

To understand and fix the error, let's take a recent example in which I have encountered the same error while trying to install snort 3 on my Ubuntu 22.04 LTS system. During installation, when I tried running ./configure_cmake.sh script to install the application from source code, I noticed ERROR! Libpcap library/headers (libpcap.a (or .so)/pcap.h) not found error on the output as shown below.

cyberithub@ubuntu:~/snort3-3.1.71.0$ ./configure_cmake.sh
./configure_cmake.sh: 486: [: Illegal number:
Build Directory : build
Source Directory: /home/cyberithub/snort3-3.1.71.0
-- The CXX compiler identification is Clang 14.0.0
-- The C compiler identification is GNU 11.4.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2")
-- Checking for module 'libdaq>=3.0.12'
-- Found libdaq, version 3.0.12
-- Found DAQ: /usr/local/lib/libdaq.so
-- Checking for module 'libdaq_static_afpacket'
-- Found libdaq_static_afpacket, version 3.0.12
-- Checking for module 'libdaq_static_fst'
-- Found libdaq_static_fst, version 3.0.12
-- Checking for module 'libdaq_static_gwlb'
-- Found libdaq_static_gwlb, version 3.0.12
-- Checking for module 'libdaq_static_savefile'
-- Found libdaq_static_savefile, version 3.0.12
-- Checking for module 'libdaq_static_trace'
-- Found libdaq_static_trace, version 3.0.12
-- Found DNET: /usr/include
-- Found FLEX: /usr/bin/flex (found suitable version "2.6.4", minimum required is "2.6.0")
-- Checking for module 'hwloc'
-- Found hwloc, version 2.7.0
-- Found HWLOC: /usr/lib/x86_64-linux-gnu/libhwloc.so
-- Checking for module 'luajit'
-- Found luajit, version 2.1.1695653777
-- Found LuaJIT: /usr/local/lib/libluajit-5.1.so (found version "2.1.1695653777")
-- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found suitable version "3.0.2", minimum required is "1.1.1")
CMake Error at /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:230 (message):

ERROR! Libpcap library/headers (libpcap.a (or .so)/pcap.h)
not found, go get it from http://www.tcpdump.org
or use the --with-pcap-* options, if you have it installed
in unusual place. Also check if your libpcap depends on another
shared library that may be installed in an unusual place (missing: PCAP_LIBRARIES PCAP_INCLUDE_DIR)
Call Stack (most recent call first):
/usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
cmake/FindPCAP.cmake:44 (find_package_handle_standard_args)
cmake/include_libraries.cmake:10 (find_package)
CMakeLists.txt:27 (include)

-- Configuring incomplete, errors occurred!
See also "/home/cyberithub/snort3-3.1.71.0/build/CMakeFiles/CMakeOutput.log".

While above error could occur due to multiple reasons but most of the time it is because of missing libpcap-dev package in the system. So to fix the error you just have to install the package by using sudo apt-get install libpcap-dev command as shown below. This command will download and install the package along with all its dependencies.

cyberithub@ubuntu:~/snort3-3.1.71.0$ sudo apt-get install libpcap-dev
[sudo] password for cyberithub:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
libluajit-5.1-2 libluajit-5.1-common
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
libpcap0.8-dev
The following NEW packages will be installed:
libpcap-dev libpcap0.8-dev
0 upgraded, 2 newly installed, 0 to remove and 25 not upgraded.
Need to get 274 kB of archives.
After this operation, 872 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://in.archive.ubuntu.com/ubuntu jammy/main amd64 libpcap0.8-dev amd64 1.10.1-4build1 [270 kB]
Get:2 http://in.archive.ubuntu.com/ubuntu jammy/main amd64 libpcap-dev amd64 1.10.1-4build1 [3,328 B]
Fetched 274 kB in 2s (158 kB/s)
Selecting previously unselected package libpcap0.8-dev:amd64.
(Reading database ... 235430 files and directories currently installed.)
Preparing to unpack .../libpcap0.8-dev_1.10.1-4build1_amd64.deb ...
Unpacking libpcap0.8-dev:amd64 (1.10.1-4build1) ...
Selecting previously unselected package libpcap-dev:amd64.
Preparing to unpack .../libpcap-dev_1.10.1-4build1_amd64.deb ...
Unpacking libpcap-dev:amd64 (1.10.1-4build1) ...
Setting up libpcap0.8-dev:amd64 (1.10.1-4build1) ...
Setting up libpcap-dev:amd64 (1.10.1-4build1) ...
Processing triggers for man-db (2.10.2-1) ...

After successfully installing the package, if you now run same ./configure_cmake.sh script again then this time you will notice that the error gets disappeared and it is now detecting libpcap header files as shown below. This confirms that the error is resolved now.

cyberithub@ubuntu:~/snort3-3.1.71.0$ ./configure_cmake.sh
./configure_cmake.sh: 486: [: Illegal number:
Build Directory : build
Source Directory: /home/cyberithub/snort3-3.1.71.0
-- The CXX compiler identification is Clang 14.0.0
-- The C compiler identification is GNU 11.4.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2")
-- Checking for module 'libdaq>=3.0.12'
-- Found libdaq, version 3.0.12
-- Found DAQ: /usr/local/lib/libdaq.so
-- Checking for module 'libdaq_static_afpacket'
-- Found libdaq_static_afpacket, version 3.0.12
-- Checking for module 'libdaq_static_fst'
-- Found libdaq_static_fst, version 3.0.12
-- Checking for module 'libdaq_static_gwlb'
-- Found libdaq_static_gwlb, version 3.0.12
-- Checking for module 'libdaq_static_savefile'
-- Found libdaq_static_savefile, version 3.0.12
-- Checking for module 'libdaq_static_trace'
-- Found libdaq_static_trace, version 3.0.12
-- Found DNET: /usr/include
-- Found FLEX: /usr/bin/flex (found suitable version "2.6.4", minimum required is "2.6.0")
-- Checking for module 'hwloc'
-- Found hwloc, version 2.7.0
-- Found HWLOC: /usr/lib/x86_64-linux-gnu/libhwloc.so
-- Checking for module 'luajit'
-- Found luajit, version 2.1.1695653777
-- Found LuaJIT: /usr/local/lib/libluajit-5.1.so (found version "2.1.1695653777")
-- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found suitable version "3.0.2", minimum required is "1.1.1")
-- Found PCAP: /usr/lib/x86_64-linux-gnu/libpcap.so
-- Performing Test PCAP_LINKS_SOLO
-- Performing Test PCAP_LINKS_SOLO - Success

Leave a Comment