Problem with libraries using winsock.h

I have a project that uses Boost.Asio and the media decoding samples that come with Intel IPP-Library. The problem is as follows. If I compile the project without a definition WIN32_LEAN_AND_MEAN, Asio complains about the notorious "winsock.h already included" error. If I define a macro, the header in another library is undefined because it relies on windows.h, including winsock.h. I tried adding winsock.h to this header manually, but it makes Boost.Asio scream again. The only solution I can think of is to go through each compilation unit and make sure that Asio is always on first. Due to the size and complexity of the project (and the ugliness of this solution), I would like to find a better way.

Thanks in advance!

+3
source share
2 answers

you can get around this if you share your source and don’t use some kind of common header in your application, in which you enter both Asio and IPP. Thus, source files that require Asio include Boost headers, source files that require IPP include IPP headers, but the header files for your classes, which should reference both, should not include external headers and, if necessary, use forwarded declarations.

+4
source

"The header in another library has undefined types"

How many? How difficult is it? Perhaps you can define these types?

0
source

Source: https://habr.com/ru/post/1722565/


All Articles