How to solve the problem of mingw compiling boost ASIO program in win7

Source: Internet
Author: User

The use of mingw to learn boost is a trigger. If you want to avoid detours, you should use the compilers that come with windows. Open-source Dongdong is really hard to see and trouble on Microsoft's platform.

Let's talk about the compiling environment: win7 64-bit flagship edition, mingw 4.4, and boost 1.53. All the libraries are generated as static libraries (. a) The source file is the first example in the boost ASIO document. The file name is changed to timer_sync.cpp.

Two problems were encountered during the connection:

The first problem is that the corresponding macro option is not specified and needs to be solved using the-D parameter. For details, refer.

The second problem is that the library ws2_32.dll is not linked.

First of all, in order to convenient command, the need to link the Library to the directory: copy the boost main directory lib directory of the libboost_date_time-mgw44-mt-1_53.a and libboost_system-mgw44-mt-1_53.a to the directory, remove-mgw44-mt when renaming (of course, if you don't feel tired of typing the command, you can also rename it to a shorter file name, depending on your preferences .)

Second, download the sw_32.dll file online.

Http://cn.dll-files.com/ws2_32.dll.html

Download and decompress the package, and copy it to the local directory.

Third, enter the following command:

Note that the macro 0x0501 is used here, indicating that the platform is XP, but win7 is compatible.

Timer_sync.exe is generated.ProgramThe program will output the string after 5 seconds.

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.