Connecting Tech Pros Worldwide Forums | Help | Site Map

Error LNK2019: unresolved external symbol

Newbie
 
Join Date: Nov 2009
Posts: 2
#1: 2 Days Ago
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_ntoa@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):

Expand|Select|Wrap|Line Numbers
  1. #ifndef A_H
  2. #define A_H
  3.  
  4. #include <WinSock2.h>
  5. #include <windows.h>
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <pcap.h>
  9. #include <string.h>
  10. #include <strsafe.h>
  11.  
  12. #include "B.h"
  13.  
  14. void got_packet(u_char *user, const struct pcap_pkthdr *header, const u_char *packet);
  15.  
  16. #endif /* A_H */
B.h looks somewhat like this (irrelevant code removed):

Expand|Select|Wrap|Line Numbers
  1. #ifndef B_H
  2. #define B_H
  3.  
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7.  
  8. __inline int Search( /* Function parameters */ );
  9.  
  10. #endif /* B_H */
Why am I getting these errors and how can I solve them?

Thank you!

Regards,
Rayne

gpraghuram's Avatar
Expert
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,258
#2: 2 Days Ago

re: Error LNK2019: unresolved external symbol


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
Newbie
 
Join Date: Nov 2009
Posts: 2
#3: 1 Day Ago

re: Error LNK2019: unresolved external symbol


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