CentOS安裝libpcap

1.安裝GCC:
  yum -y install gcc-c++html

2.安裝flex: 
  yum -y install flex 
  沒有flex,直接安裝libpcap會提示"Your operating system's lex is insufficient to compile libpcap"錯誤;mysql

3.安裝bison
  yum -y install bison
  前面安裝的是flex,就須要搭配bison,如不會提示"don't have both flex and bison;reverting to lex/yacc"錯誤;linux

4.安裝 libpcap
  下載地址:http://www.tcpdump.org/
  下載版本:wget -c http://www.tcpdump.org/release/libpcap-1.5.3.tar.gzc++

   解壓軟件包:tar zxf libpcap-1.0.0.tar.gzsql

  進入解壓後的目錄,輸入命令行:
   命令以下:
   ./configure
   make
   make installvim

5.簡單的例子測試一下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);
  }tcp

  編譯指令:gcc -o device device.c -lpcap
  備註:編譯時要使用libpcap的參數-lpcap,不然會提示「pcap_lookupdev 未定義的引用」的錯誤;
  運行指令:./device測試

轉載:http://www.tcpdump.org/release/libpcap-1.5.3.tar.gzflex

http://blog.sina.com.cn/s/blog_6f289b0e01014jst.htmlspa

運行遇到錯誤解決辦法:

error while loading shared libraries: libpcap.so.1: cannot open shared object file: No such file or

 

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

//AUTHOR:lanyang123456

//DATE:2011-11-10

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

 

Linux系統下,運行sniff程序須要libpcap庫。

首先下載安裝該庫,下載地址: http://www.tcpdump.org/

點擊DOWNLOADS

 

下載後

(1)解壓

(2)進入解壓後文件目錄, ./configure

(3)make install

默認安裝目錄/usr/local/lib

 

編譯sniff程序經過,運行sniff程序時,出現以下錯誤:

./sn: error while loadingshared libraries: libpcap.so.1: cannot open shared object file: No such file ordirectory

 

因爲libpcap已經安裝,因此是程序沒法找到庫所在的位置的緣由。

解決辦法:

將libpcap.so.1所在目錄添加到文件/etc/ld.so.conf中,

打開ld.so.conf文件,而後添加一行/usr/local/lib:

includeld.so.conf.d/*.conf //原來的內容

/usr/local/lib

而後保存,再終端下執行 ldconfig。

再運行sniff程序,OK。 

有時用tar解壓文件.錯誤以下:

gzip: stdin: unexpectedend of file tar: Unexpected EOF in archive tar: Unexpected EOF in archive tar:Error is not recoverable: exiting now

緣由:

文件被破壞,從新下載。

轉載:http://blog.csdn.net/lanyang123456/article/details/6956093

 

libnet.so.1: cannot open shared object file: No such file or directory 

安裝了libnet
./configure
make
make install 
程序編譯正確,可是執行的時候出現以下問題
libnet.so.1: cannot open shared object file: No such file or directory  
這種問題常常出現,緣由是程序執行時尋找的是/usr/lib下的庫,而libnet默認安裝到了/usr/local/lib

解決方法:

1.將全部文件 /usr/local/lib的全部文件拷貝到/usr/lib下,應該能夠,沒有嘗試。
2.vim /etc/ld.so.conf.d/ld.libnet.so.conf
添加 /usr/local/lib
退出保存
ldconfig
而後在執行程序。ok。
參考http://www.2cto.com/os/201306/222628.html
 
cannot open shared object file: No such file or directory解決
 
./move_db: error while loading shared libraries: lib mysqlclient.so.15: cannot 
open shared object file: No such file or directory 
 
第一步:確認有哪些Lib沒法Load 
>ldd move_db 
linux-gate.so.1 => (0x0089c000) 
libmysqlclient.so.15 => not found 
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00cfa000) 
libm.so.6 => /lib/libm.so.6 (0x00804000) 
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x009f8000) 
libc.so.6 => /lib/libc.so.6 (0x0069e000) 
/lib/ld-linux.so.2 (0x0067b000) 
 
第二步: 系統要確認動態庫的地址,把動態庫的路徑放到/etc/ld.so.conf中 
建議:在/etc/ld.so.conf.d/上新建動態庫相應的文件配置文件*.conf, 
在該文件中填上該動態庫的絕對路徑 
此例: 
vim /etc/ld.so.conf.d/ld.mysql.so.conf 
/usr/local/mysql/lib 
 
第三步:運行ldconfig   重建/etc/ld.so.cache
相關文章
相關標籤/搜索