Error lnk2019: external symbols that cannot be parsed (solution)

Source: Internet
Author: User
Tags visual studio 2010

When using C ++ for socket programming, the following error occurs:

 

1> ------ generated: Project: netclient, configuration: Debug Win32 ------
1> netclient. cpp
1> C:/My Documents ents/Visual Studio 2010/projects/NETServer/netclient. CPP (48): Warning c4996: 'gets': This function or variable may be unsafe. consider using gets_s instead. to disable deprecation, use _ crt_secure_no_warnings. see online help for details.
1> D:/vs2010/VC/include/stdio. H (277): see the "gets" statement.
1> C:/My Documents ents/Visual Studio 2010/projects/NETServer/netclient. CPP (59): Warning c4996: 'sprintf': This function or variable may be unsafe. consider using sprintf_s instead. to disable deprecation, use _ crt_secure_no_warnings. see online help for details.
1> D:/vs2010/VC/include/stdio. H (371): see the "sprintf" statement.
1> netclient. OBJ: Error lnk2019: external symbol that cannot be parsed _ closesocket @ 4, which is referenced in function _ main
1> netclient. OBJ: Error lnk2019: external symbol that cannot be parsed _ inet_ntoa @ 4, which is referenced in function _ main
1> netclient. OBJ: Error lnk2019: external symbol that cannot be parsed _ recvfrom @ 24, which is referenced in function _ main
1> netclient. OBJ: Error lnk2019: external symbol that cannot be parsed _ sendto @ 24, which is referenced in function _ main
1> netclient. OBJ: Error lnk2019: external symbol that cannot be parsed _ htons @ 4, which is referenced in function _ main
1> netclient. OBJ: Error lnk2019: external symbol that cannot be parsed _ inet_addr @ 4, which is referenced in function _ main
1> netclient. OBJ: Error lnk2019: external symbol that cannot be parsed _ socket @ 12, which is referenced in function _ main
1> netclient. OBJ: Error lnk2019: external symbol that cannot be parsed _ wsacleanup @ 0, which is referenced in function _ main
1> netclient. OBJ: Error lnk2019: external symbol that cannot be parsed _ wsastartup @ 8, which is referenced in function _ main
1> C:/My Documents ents/Visual Studio 2010/projects/NETServer/debug/netclient.exe: Fatal error lnk1120: 9 unresolvable External commands
============ Generate: 0 successful, 1 failed, 0 latest, skipped 0 ==========


The solution is as follows:



Add the following code after the include statement of the CPP file:

 

# Pragma comment (Lib, "ws2_32.lib ")

# Pragma comment (Lib, "ws2_32.lib ")

 

This will solve the problem.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.