当前位置:  技术问答>linux和unix

GCC编译出现undefined reference to `pcap_lex'

    来源: 互联网  发布时间:2017-02-28

    本文导语:  代码如下 #include  #include  #include   /* GIMME a libpcap plz! */ #include  #include  #include  #include  int main(int argc, char **argv) {   char *dev; /* name of the device to use */    char *net; /* dot notation of the network address ...

代码如下
#include 
#include 
#include   /* GIMME a libpcap plz! */
#include 
#include 
#include 
#include 

int main(int argc, char **argv)
{
  char *dev; /* name of the device to use */ 
  char *net; /* dot notation of the network address */
  char *mask;/* dot notation of the network mask    */
  int ret;   /* return code */
  char errbuf[PCAP_ERRBUF_SIZE];
  bpf_u_int32 netp; /* ip          */
  bpf_u_int32 maskp;/* subnet mask */
  struct in_addr addr;

  /* ask pcap to find a valid device for use to sniff on */
  dev = pcap_lookupdev(errbuf);

  /* error checking */
  if(dev == NULL)
  {
   printf("%sn",errbuf);
   exit(1);
  }

  /* print out device name */
  printf("DEV: %sn",dev);

  /* ask pcap for the network address and mask of the device */
  ret = pcap_lookupnet(dev,&netp,&maskp,errbuf);

  if(ret == -1)
  {
   printf("%sn",errbuf);
   exit(1);
  }

  /* get the network address in a human readable form */
  addr.s_addr = netp;
  net = inet_ntoa(addr);

  if(net == NULL)/* thanks Scott :-P */
  {
    perror("inet_ntoa");
    exit(1);
  }

  printf("NET: %sn",net);

  /* do the same as above for the device's mask */
  addr.s_addr = maskp;
  mask = inet_ntoa(addr);
  
  if(mask == NULL)
  {
    perror("inet_ntoa");
    exit(1);
  }
  
  printf("MASK: %sn",mask);

  return 0;
}

|
很有可能是ls说的

|
sudo apt-get install libpcap-dev

    
 
 

您可能感兴趣的文章:

  • arm-linux-gcc交叉编译出错,但gcc编译没错,什么原因呢???
  • 嵌入式linux开发:一段代码在windows平台用VC编译运行正常,在linux平台用gcc编译运行正常,但是用arm-linux-gcc编译在嵌入式板子上运行就不正常.
  • GCC3.4可以编译2.4内核吗 如何查看某版本内核是用哪个版本gcc编译的
  • 使用popen来执行gcc命令,如何根据读出来的gcc的输出来判断gcc是否编译成功?
  • 问:关于gcc编译器和g++编译器
  • 求一个编译好的的gcc编译器
  • 编译GCC时能不能只编译C/C++的编译器?
  • gcc编译时出错,gcc: installation problem, cannot exec `as': 没有那个文件或目录!!!求助呀呀!!!!!
  • 建立较差编译环境,编译gcc-3.4.4出错
  • gcc与arm-linux-gcc编译的问题???
  • Linux下gcc编译时,如何以静态链接的形式编译?
  • Solaris8,安装了iconv,gcc和gcclib,然后用gcc编译c程序出错。
  • 使用eclipse 加入arm-elf-gcc 或arm-linux-gcc 编译器为什么不好使
  • 是否必须用同一版本GCC编译内核、应用程序、库甚至GCC自己?
  • linux x86_64下由于拷贝gcc的lib目录导致gcc编译器出错
  • GCC编译程序时,有自定义头文件,提示找不到该头文件,但他就在这个目录中,如何设置GCC参数?
  • 使用gcc编译器进行代码编译出来的程序是否遵循gpl协议
  • 为什么g++编译通过了,而gcc却编译通过不了???
  • ubuntu 10.10出现极其诡异的情况,使用gcc编译没任何反应,可以继续输入,但是不提示任何错误;使用make编译效果一样;
  • 求助:当用 gcc 编译时没,加上优化选项 -02 ,可是提示是 gcc: unrecognized option `-02'
  • 在LINUX GCC 编译错误 UnDefined reference to "pthread_creat"
  •  
    本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
    本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。












  • 相关文章推荐
  • Linux下GCC内置原子操作函数(多线程资源访问)介绍
  • 命令:mips_fp_le-gcc,mipsel-gcc 是什么意思?跟一般的gcc有什么区别?
  • 怎样升级我的GCC呀,我用的RH7.2,GCC 2.96 ,我从网上下载了一个gcc-3.2.3.tar.gz
  • arm-elf-gcc 和 arm-linux-gcc有什么区别?arm-elf-gcc里的elf代表什么?
  • gcc-ccore、avr-gcc及arm-gcc的区别
  • gcc在哪里?bash:gcc:command not found
  • 如何删掉GCC3.0(我需要GCC2.0-----)
  • Windows版GCC TDM-GCC
  • 急问:如何卸掉gcc 3.2庄gcc 2.96
  • 有人遇到过吗,在安装GCC时提示,"checking gcc ...no "
  • GCC无法安装的问题,希望有人帮我( Debian 4.04ra无法安装GCC)
  • 一套未安装gcc的Linux中安装gcc rpm包时时出现错误
  • 下了一个GCC3.0包用tar xjfv gcc-3.0.tar.bz2解压后出现一堆文
  • 请问如何安装rpm格式的gcc如gcc-3.2.2-5.src.rpm,谢谢
  • 在redhat9下,如何将gcc3.x改为gcc2.x?
  • 我在Solaris8上安装了gcc3.3Solaris8,但是总是出错!错误如下:gcc: syntax error at line 1: `(' unexpected
  • Linux RadHat7.2 系统,无gcc、cc。请问怎么安装gcc和cc?哪里可以下载cc?
  • 我在安装Red Hat Linux 时没有装到gcc,怎么才能在之后把gcc装上?
  • makefile中加入动态库编译,在gcc下正常,在arm gcc下说库找不到?
  • 疑惑softfloat的问题,并求arm-linux-gcc和arm-linux-softfloat-gcc4.1.1
  • 安装Oracel,关于ln -s /usr/i386-glibc-2.1-linux/bin/i386-glibc21-linux-gcc gcc的问题


  • 站内导航:


    特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

    ©2012-2021,,E-mail:www_#163.com(请将#改为@)

    浙ICP备11055608号-3