Search code examples
c++boost-asiointel-ipp

Problem with libraries using winsock.h


I have a project that uses Boost.Asio and the Media-Decoding-Samples that come with the Intel IPP-Library. The problem is the following. If I compile the project without defining WIN32_LEAN_AND_MEAN, Asio complains with the infamous "winsock.h already included" error. If I define the macro, a header in the other library has undefined types, because it relies on windows.h including winsock.h. I tried adding winsock.h to that header manually, but this makes Boost.Asio cry out again. The only solution I can think of would be to go through every compilation unit and make sure that Asio is always included first. Due to the size and complexity of the project (and the uglyness of that solution) I would like to find a better way.

Thanks in advance !


Solution

  • you can get around this if you split up your source and make sure not to use some kind of common header in your application in which you incude both Asio and IPP. So the source files needing Asio include Boost headers, the source files needing IPP include the IPP headers, but the header files for your classes that need to refer to both should not include any external headers, and use forward declarations if needed.