Solve boost: asio WinSock. h has already been included

Source: Internet
Author: User

Recently, the code of the new face detection algorithm always prompts WinSock. h has already been included. Someone has provided a solution and reprinted it to remember it.

When you start to use the boost: asio library, the following error occurs during compilation:

Fatal error C1189: # error: WinSock. h has already been pinned DED

Check the boost code that throws this error. It was originally defined as _ WINSOCKAPI _, but not _ WINSOCK2API _

Where do we define _ WINSOCKAPI?

Later, I checked it on the Internet. It turned out that I included the Windows. h header file, and the Windows. h header file included the old WinSock. h file.

It is easy to know the cause. After trying, there are three methods to solve this error:

1. Define the macro WIN32_LEAN_AND_MEAN before Windows. h. (WIN32_LEAN_AND_MEAN indicates that it does not contain materials that are rarely used and biased)

2. Include winsock2.h before Windows. h.

3. Include asio. hpp before Windows. h.

 

From http://blog.csdn.net/gzlyb/article/details/5870326

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.