我用winpcap捕获数据包,想把它保存到文件里,通过一个线程来实现,写了一个函数代码如下:
void dumpfliefun(void *list)
{
    ARGS *args;
    TComboBox *combobox;
    args=(ARGS *)list;
    combobox=args->combobox;
    pcap_if_t *alldevs;
    pcap_if_t *d;
    int inum;
    int i=0;
    pcap_t *adhandle;
    int res;
    struct pcap_pkthdr *header;
    const u_char *pkt_data;
    u_int netmask;
    char errbuf[PCAP_ERRBUF_SIZE];
    pcap_dumper_t *dumpfile;
    /* Retrieve the device list */
    if (pcap_findalldevs(&alldevs, errbuf) == -1)
    {
        ShowMessage("Error in pcap_findalldevs");
        exit(0);
    }

    for(d=alldevs;d;d=d->next)
    {
        i++;
    }

    if(i==0)
    {
        ShowMessage("No interfaces found! Make sure WinPcap is installed.");
        exit(0);
    }

    inum=StrToInt(combobox->Text);

    if(inum < 1 || inum > i)
    {
        ShowMessage("Interface number out of range.");
        /* Free the device list */
        pcap_freealldevs(alldevs);
        exit(0);
    }

    /* Jump to the selected adapter */
    for(d=alldevs, i=0; i < inum-1 ;d=d->next, i++);

    /* Open the adapter */
    if ( (adhandle= pcap_open_live(d->name, // name of the device
        65536,    // portion of the packet to capture.
        // 65536 grants that the whole packet will be captured on all the MACs.
        1,        // promiscuous mode
        1000,      // read timeout
        errbuf    // error buffer
        ) ) == NULL)
    {
        ShowMessage("Unable to open the adapter.Maybe it is not supported by WinPcap.");
        /* Free the device list */
        pcap_freealldevs(alldevs);
        exit(0);
    }
        /* Check the link layer. We support only Ethernet for simplicity. */
    if(pcap_datalink(adhandle) != DLT_EN10MB)
    {
        ShowMessage("This program works only on Ethernet networks.");
        /* Free the device list */
        pcap_freealldevs(alldevs);
        exit(0);
    }

    if(d->addresses != NULL)
        /* Retrieve the mask of the first address of the interface */
        netmask=((struct sockaddr_in *)(d->addresses->netmask))->sin_addr.S_un.S_addr;
    else
        /* If the interface is without addresses we suppose to be in a C class network */
        netmask=0xffffff;

    /* At this point, we don't need any more the device list. Free it */
    pcap_freealldevs(alldevs);
   
    /*  打开文件  */
    dumpfile=pcap_dump_open(adhandle,"Packet.dat");
    if(dumpfile==NULL)
    {
      ShowMessage("Error  opening  output  file.");
      exit(0);
    }

   
    /* Retrieve the packets from the file */
    while((res = pcap_next_ex( adhandle, &header, &pkt_data)) >= 0)
    {
      if(res==0)
      //timeout elasped
      continue;
      //将数据保存到文件
      pcap_dump((unsigned char*)dumpfile,header,pkt_data);
    }

        if(res == -1)
        {
        ShowMessage("Error reading the packets");
      }
}
出现了[Linker Error] Unresolved external 'dumpfilefun(void *)' referenced from C:\PROGRAM FILES\BORLAND\CBUILDER6\PROJECTS\NEWPOJ\NEWU
这个错误,高手这应该怎么改!!

C/C++ code
// Link error,你这个函数的实现体 连接不到 // 具体仔细检查代码吧,看看这个单元的实现代码有没有加入工程中一起编译连接

把这段代码所在的单元(.cpp)或者其目标文件(.obj)添加到你的工程当中,得新编译链接。

谢谢各位,原来我写错了函数名!!^_^给分了!