Install libpcap on centos

Source: Internet
Author: User

1. Install GCC:
Yum-y install gcc-C ++

2. Install flex:
Yum-y install flex
If no flex is available, the system prompts "your operating system's Lex is insufficient to compile libpcap" When libpcap is directly installed;

3. Install bison
Yum-y install bison
If Flex is installed earlier, Bison is required. If the message "don't have both flex and bison; reverting to lex/YACC" is not displayed;

4. Install libpcap
: Http://www.tcpdump.org/
Download version: wget-C http://www.tcpdump.org/release/libpcap-1.5.3.tar.gz

Decompress package: Tar zxf libpcap-1.0.0.tar.gz

Enter the decompressed directory and enter the command line:
The command is as follows:
./Configure
Make
Make install

5. A simple example to test libpcap:
// Device. c
# Include <stdio. h>
# Include <pcap. h>
Int main (INT argc, char * argv []) {
Char * Dev, errbuf [pcap_errbuf_size];
Dev = pcap_lookupdev (errbuf );
If (Dev = NULL ){
Fprintf (stderr, "couldn't find default device: % s \ n", errbuf );
Return (2 );
}
Printf ("device: % s \ n", Dev );
Return (0 );
}

Compilation command: gcc-O device. C-lpcap
Note: libpcap parameter-lpcap should be used during compilation; otherwise, the error "pcap_lookupdev undefined reference" will be prompted;
Run the command:./Device

Reprinted: http://www.tcpdump.org/release/libpcap-1.5.3.tar.gz

Http://blog.sina.com.cn/s/blog_6f289b0e01014jst.html

Solution to running errors:

Error while loading shared libraries: Libpcap. so.1: cannot open shared object file: no such file or

 

//-----------------------------------------------------------

// Author: lanyang123456

// Date: 2011-11-10

//-----------------------------------------------------------

 

In Linux, The libpcap library is required to run the sniff program.

First download and install the library,: http://www.tcpdump.org/

Click downloads

 

After download

(1) Extract

(2) enter the file directory after decompression,./configure

(3) make install

Default installation directory/usr/local/lib

 

When the sniff program passes the compilation and runs the sniff program, the following error occurs:

./SN: Error while loadingshared libraries: Libpcap. so.1: cannot open shared object file: no such file ordirectory

 

Because libpcap has been installed, the program cannot find the location of the library.

Solution:

Add the directory of Libpcap. so.1 to the/etc/lD. So. conf file,

Open the lD. So. conf file and add a line/usr/local/lib:

Includeld. So. conf. d/*. conf // original content

/Usr/local/lib

Save and run ldconfig on the terminal.

Run the sniff program again. OK.

Sometimes decompress the file with tar. The error is as follows:

Gzip: stdin: unexpectedend of file tar: Unexpected EOF in archive tar: error is not recoverable: exiting now

Cause:

The file is damaged and downloaded again.

Reprinted: http://blog.csdn.net/lanyang123456/article/details/6956093

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.