Error LNK2019: unresolved external symbol

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hjazz
    New Member
    • Nov 2009
    • 5

    Error LNK2019: unresolved external symbol

    Hi all,
    I'm new to VS, and I'm using Visual Studio .NET 2003.

    I'm trying to write a program which uses pcap libraries. However, I keep getting the following errors:

    error LNK2019: unresolved external symbol __imp__inet_nto a@4 referenced in function _got_packet
    error LNK2019: unresolved external symbol __imp__ntohs@4 referenced in function _got_packet
    error LNK2019: unresolved external symbol _Search referenced in function _got_packet
    error LNK2019: unresolved external symbol _memcpy_s referenced in function _got_packet

    The function got_packet is implemented in A.c, and the function Search is implemented in B.c. I also have corresponding header files A.h and B.h.

    A.h looks somewhat like this (irrelevant code removed):

    Code:
    #ifndef A_H
    #define A_H
    
    #include <WinSock2.h>
    #include <windows.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <pcap.h>
    #include <string.h>
    #include <strsafe.h>
    
    #include "B.h"
    
    void got_packet(u_char *user, const struct pcap_pkthdr *header, const u_char *packet);
    
    #endif /* A_H */
    B.h looks somewhat like this (irrelevant code removed):

    Code:
    #ifndef B_H
    #define B_H
    
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    
    __inline int Search( /* Function parameters */ );
    
    #endif /* B_H */
    Why am I getting these errors and how can I solve them?

    Thank you!

    Regards,
    Rayne
  • gpraghuram
    Recognized Expert Top Contributor
    • Mar 2007
    • 1275

    #2
    I think you havent included the winsock library in linker options.
    Try to include winsock and winsock (libraries) and i think the issue will get resolved.


    Raghu

    Comment

    • hjazz
      New Member
      • Nov 2009
      • 5

      #3
      Thanks. I added ws2_32.lib and took out the __inline from my Search function, and the program ran successfully.

      Comment

      Working...